Getting Started
This guide will help you integrate Better Auth Infrastructure into your application.
Prerequisites
Before you begin, make sure you have:
- A working Better Auth installation
- An account & API Key from the Better Auth Infrastructure dashboard
Environment Variables
Once you've gotten the API Key from the infrastructure dashboard,
go ahead and add the BETTER_AUTH_API_KEY environment variable in your production environment variables.
# Required: Your Better Auth Infrastructure API key
BETTER_AUTH_API_KEY=your_api_key_hereYou can get your API key by signing-up and creating a new project in the Better Auth Infrastructure dashboard.
Server Setup
Basic Configuration
Add the dash() plugin to your Better Auth configuration:
import { betterAuth } from "better-auth";
import { dash } from "@better-auth/infra";
export const auth = betterAuth({
// ... your existing Better Auth config
plugins: [
dash({
apiKey: process.env.BETTER_AUTH_API_KEY,
}),
],
});If you're on pro plan or above, you can use the sentinel() plugin to enable security checks, abuse protection, and more:
import { betterAuth } from "better-auth";
import { dash, sentinel } from "@better-auth/infra";
export const auth = betterAuth({
plugins: [
dash({ /* ... */ }),
sentinel({
apiKey: process.env.BETTER_AUTH_API_KEY,
})
],
});Client Setup
Basic Client Configuration
Add the client plugins to your auth client:
import { createAuthClient } from "better-auth/client";
import { dashClient, sentinelClient } from "@better-auth/infra/client";
export const authClient = createAuthClient({
plugins: [
dashClient(),
sentinelClient({
autoSolveChallenge: true, // Automatically solve PoW challenges
}),
],
});Plugin Overview
dash()- Enables analytics tracking, audit logging, dashboard admin APIs, and moresentinel()- Enables security checks and abuse protection
You can use either plugin independently, but using both together provides the full Better Auth Infrastructure experience.
Next Steps
Now that you have the basic setup, explore these topics:
- Dashboard - Analytics, activity tracking, and admin APIs
- Audit Logs - Track and query authentication events
- Sentinel - Configure advanced security
- Email Service - Set up transactional emails
- SMS Service - Enable SMS verification