mirror of
https://github.com/better-auth/better-auth.git
synced 2026-10-20 20:26:55 -05:00
docs: note Kysely is now an optional dependency
Pages that show a raw database connection now tell readers to install kysely (the built-in adapter's engine, no longer auto-installed). Replaces the obsolete better-auth/minimal bundle-size guidance, since the default import already loads Kysely only when a raw connection is used.
This commit is contained in:
@@ -59,6 +59,12 @@ export const auth = betterAuth({
|
||||
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
For more information, read Kysely's documentation to the [MssqlDialect](https://kysely-org.github.io/kysely-apidoc/classes/MssqlDialect.html).
|
||||
</Callout>
|
||||
|
||||
@@ -26,6 +26,12 @@ export const auth = betterAuth({
|
||||
});
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
For more information, read Kysely's documentation to the
|
||||
[MySQLDialect](https://kysely-org.github.io/kysely-apidoc/classes/MysqlDialect.html).
|
||||
|
||||
@@ -22,6 +22,12 @@ export const auth = betterAuth({
|
||||
});
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
For more information, read Kysely's documentation to the
|
||||
[PostgresDialect](https://kysely-org.github.io/kysely-apidoc/classes/PostgresDialect.html).
|
||||
|
||||
@@ -23,6 +23,12 @@ export const auth = betterAuth({
|
||||
});
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
<Callout>
|
||||
For more information, read Kysely's documentation to the
|
||||
[SqliteDialect](https://kysely-org.github.io/kysely-apidoc/classes/SqliteDialect.html).
|
||||
|
||||
@@ -63,6 +63,12 @@ export const auth = betterAuth({
|
||||
type Session = typeof auth.$Infer.Session
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
## 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.
|
||||
|
||||
@@ -34,6 +34,12 @@ Before starting the migration process, set up Better Auth in your project. Follo
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
</Step>
|
||||
|
||||
<Step>
|
||||
|
||||
@@ -34,6 +34,12 @@ Before starting the migration process, set up Better Auth in your project. Follo
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
</Step>
|
||||
|
||||
<Step>
|
||||
|
||||
@@ -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.
|
||||
</Callout>
|
||||
|
||||
## 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`:
|
||||
|
||||
<Tabs items={["Prisma", "Drizzle", "MongoDB"]}>
|
||||
<Tab value="Prisma">
|
||||
```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"
|
||||
}),
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab value="Drizzle">
|
||||
```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"
|
||||
}),
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
|
||||
<Tab value="MongoDB">
|
||||
```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),
|
||||
});
|
||||
```
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Callout type="warning">
|
||||
**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)
|
||||
</Callout>
|
||||
Apps that pass a raw connection (the built-in adapter) should install Kysely with `npm install kysely`.
|
||||
|
||||
@@ -39,6 +39,12 @@ Before starting the migration process, set up Better Auth in your project. Follo
|
||||
}),
|
||||
})
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
</Step>
|
||||
|
||||
<Step>
|
||||
|
||||
@@ -66,6 +66,12 @@ Before getting started, let’s review which WorkOS authentication features are
|
||||
});
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
### 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).
|
||||
|
||||
@@ -115,6 +115,12 @@ description: Learn how to configure Better Auth in your project.
|
||||
</Tab>
|
||||
</Tabs>
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
Alternatively, if you prefer to use an ORM, you can use one of the built-in adapters.
|
||||
|
||||
<Tabs items={["drizzle", "prisma", "mongodb"]}>
|
||||
|
||||
@@ -225,6 +225,12 @@ export const auth = betterAuth({
|
||||
})
|
||||
```
|
||||
|
||||
<Callout type="info">
|
||||
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.
|
||||
</Callout>
|
||||
|
||||
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).
|
||||
|
||||
Reference in New Issue
Block a user