diff --git a/docs/content/docs/adapters/mssql.mdx b/docs/content/docs/adapters/mssql.mdx index ba1b4d3c0e..e639587973 100644 --- a/docs/content/docs/adapters/mssql.mdx +++ b/docs/content/docs/adapters/mssql.mdx @@ -59,6 +59,12 @@ export const auth = betterAuth({ ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + For more information, read Kysely's documentation to the [MssqlDialect](https://kysely-org.github.io/kysely-apidoc/classes/MssqlDialect.html). diff --git a/docs/content/docs/adapters/mysql.mdx b/docs/content/docs/adapters/mysql.mdx index 256c27d765..f254e9fa28 100644 --- a/docs/content/docs/adapters/mysql.mdx +++ b/docs/content/docs/adapters/mysql.mdx @@ -26,6 +26,12 @@ export const auth = betterAuth({ }); ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + For more information, read Kysely's documentation to the [MySQLDialect](https://kysely-org.github.io/kysely-apidoc/classes/MysqlDialect.html). diff --git a/docs/content/docs/adapters/postgresql.mdx b/docs/content/docs/adapters/postgresql.mdx index 0bf2da2402..1aac6fb95f 100644 --- a/docs/content/docs/adapters/postgresql.mdx +++ b/docs/content/docs/adapters/postgresql.mdx @@ -22,6 +22,12 @@ export const auth = betterAuth({ }); ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + For more information, read Kysely's documentation to the [PostgresDialect](https://kysely-org.github.io/kysely-apidoc/classes/PostgresDialect.html). diff --git a/docs/content/docs/adapters/sqlite.mdx b/docs/content/docs/adapters/sqlite.mdx index b5aa3d96f5..a70f637974 100644 --- a/docs/content/docs/adapters/sqlite.mdx +++ b/docs/content/docs/adapters/sqlite.mdx @@ -23,6 +23,12 @@ export const auth = betterAuth({ }); ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + For more information, read Kysely's documentation to the [SqliteDialect](https://kysely-org.github.io/kysely-apidoc/classes/SqliteDialect.html). diff --git a/docs/content/docs/concepts/typescript.mdx b/docs/content/docs/concepts/typescript.mdx index 9432e082c8..a8e8e829a3 100644 --- a/docs/content/docs/concepts/typescript.mdx +++ b/docs/content/docs/concepts/typescript.mdx @@ -63,6 +63,12 @@ export const auth = betterAuth({ type Session = typeof auth.$Infer.Session ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + ## Additional Fields Better Auth allows you to add additional fields to the user and session objects. All additional fields are properly inferred and available on the server and client side. diff --git a/docs/content/docs/guides/auth0-migration-guide.mdx b/docs/content/docs/guides/auth0-migration-guide.mdx index a6f3ddf888..d4bc32cd25 100644 --- a/docs/content/docs/guides/auth0-migration-guide.mdx +++ b/docs/content/docs/guides/auth0-migration-guide.mdx @@ -34,6 +34,12 @@ Before starting the migration process, set up Better Auth in your project. Follo }), }) ``` + + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + diff --git a/docs/content/docs/guides/clerk-migration-guide.mdx b/docs/content/docs/guides/clerk-migration-guide.mdx index 1e6ef99a30..68d03740b2 100644 --- a/docs/content/docs/guides/clerk-migration-guide.mdx +++ b/docs/content/docs/guides/clerk-migration-guide.mdx @@ -34,6 +34,12 @@ Before starting the migration process, set up Better Auth in your project. Follo }), }) ``` + + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + diff --git a/docs/content/docs/guides/optimizing-for-performance.mdx b/docs/content/docs/guides/optimizing-for-performance.mdx index d3ee57e436..a320769414 100644 --- a/docs/content/docs/guides/optimizing-for-performance.mdx +++ b/docs/content/docs/guides/optimizing-for-performance.mdx @@ -175,64 +175,8 @@ Optimizing database performance is essential to get the best out of Better Auth. We intend to add indexing support in our schema generation tool in the future. -## Bundle Size Optimization +## Bundle Size -If you're using custom adapters (like Prisma, Drizzle, or MongoDB), you can reduce your bundle size by using `better-auth/minimal` instead of `better-auth`. This version excludes Kysely, which is only needed when using direct database connections. +Better Auth loads Kysely lazily, only when you pass a raw database connection. If you configure `database` with an ORM adapter (Drizzle, Prisma, or MongoDB), Kysely is never loaded or bundled, so there is nothing extra to do for a smaller bundle. -### Usage - -Simply import from `better-auth/minimal` instead of `better-auth`: - - - - ```ts title="auth.ts" - import { betterAuth } from "better-auth/minimal"; // [!code highlight] - import { prismaAdapter } from "better-auth/adapters/prisma"; - import { PrismaClient } from "@prisma/client"; - - const prisma = new PrismaClient(); - - export const auth = betterAuth({ - database: prismaAdapter(prisma, { - provider: "postgresql", // or "mysql", "sqlite" - }), - }); - ``` - - - - ```ts title="auth.ts" - import { betterAuth } from "better-auth/minimal"; // [!code highlight] - import { drizzleAdapter } from "better-auth/adapters/drizzle"; - import { db } from "./database"; - - export const auth = betterAuth({ - database: drizzleAdapter(db, { - provider: "pg", // or "mysql", "sqlite" - }), - }); - ``` - - - - ```ts title="auth.ts" - import { betterAuth } from "better-auth/minimal"; // [!code highlight] - import { mongodbAdapter } from "better-auth/adapters/mongodb"; - import { MongoClient } from "mongodb"; - - const client = new MongoClient(process.env.DATABASE_URL!); - const db = client.db(); - - export const auth = betterAuth({ - database: mongodbAdapter(db), - }); - ``` - - - - - **Limitations:** - - * Direct database connections are not supported (you must use an adapter) - * Built-in migrations are not supported. Use external migration tools (or use `better-auth` if you need built-in migration support) - +Apps that pass a raw connection (the built-in adapter) should install Kysely with `npm install kysely`. diff --git a/docs/content/docs/guides/supabase-migration-guide.mdx b/docs/content/docs/guides/supabase-migration-guide.mdx index e02744fb6c..ce222b2dc0 100644 --- a/docs/content/docs/guides/supabase-migration-guide.mdx +++ b/docs/content/docs/guides/supabase-migration-guide.mdx @@ -39,6 +39,12 @@ Before starting the migration process, set up Better Auth in your project. Follo }), }) ``` + + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + diff --git a/docs/content/docs/guides/workos-migration-guide.mdx b/docs/content/docs/guides/workos-migration-guide.mdx index 63225b7ebe..0bdc4eafc0 100644 --- a/docs/content/docs/guides/workos-migration-guide.mdx +++ b/docs/content/docs/guides/workos-migration-guide.mdx @@ -66,6 +66,12 @@ Before getting started, let’s review which WorkOS authentication features are }); ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + ### Email & Password Enable Email & Password authentication as shown below. Since WorkOS verifies each user’s email by default, this setup is similar to the default behavior. You can adjust it if needed. For more information, see the [email/password authentication documentation](/docs/authentication/email-password). diff --git a/docs/content/docs/installation.mdx b/docs/content/docs/installation.mdx index 4a861c7fa9..a36b9abf05 100644 --- a/docs/content/docs/installation.mdx +++ b/docs/content/docs/installation.mdx @@ -115,6 +115,12 @@ description: Learn how to configure Better Auth in your project. + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + Alternatively, if you prefer to use an ORM, you can use one of the built-in adapters. diff --git a/docs/content/docs/reference/options.mdx b/docs/content/docs/reference/options.mdx index 46b9986f4c..3778142173 100644 --- a/docs/content/docs/reference/options.mdx +++ b/docs/content/docs/reference/options.mdx @@ -225,6 +225,12 @@ export const auth = betterAuth({ }) ``` + + Passing a raw database connection uses Better Auth's built-in Kysely adapter. + Install Kysely alongside Better Auth with `npm install kysely`. ORM adapters + (Drizzle, Prisma, MongoDB) don't need it. + + Better Auth supports various database configurations including [PostgreSQL](/docs/adapters/postgresql), [MySQL](/docs/adapters/mysql), and [SQLite](/docs/adapters/sqlite). Read more about [databases](/docs/concepts/database).