Skip to content

Commit d00a2c8

Browse files
use nextCookies auth plugin
1 parent b961315 commit d00a2c8

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

apps/nextjs/src/auth/server.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import "server-only";
22

33
import { cache } from "react";
44
import { headers } from "next/headers";
5+
import { nextCookies } from "better-auth/next-js";
56

67
import { initAuth } from "@acme/auth";
78

@@ -20,6 +21,7 @@ export const auth = initAuth({
2021
secret: env.AUTH_SECRET,
2122
discordClientId: env.AUTH_DISCORD_ID,
2223
discordClientSecret: env.AUTH_DISCORD_SECRET,
24+
extraPlugins: [nextCookies()],
2325
});
2426

2527
export const getSession = cache(async () =>

packages/auth/src/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
import type { BetterAuthOptions } from "better-auth";
1+
import type { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
22
import { expo } from "@better-auth/expo";
33
import { betterAuth } from "better-auth";
44
import { drizzleAdapter } from "better-auth/adapters/drizzle";
55
import { oAuthProxy } from "better-auth/plugins";
66

77
import { db } from "@acme/db/client";
88

9-
export function initAuth(options: {
9+
export function initAuth<
10+
TExtraPlugins extends BetterAuthPlugin[] = [],
11+
>(options: {
1012
baseUrl: string;
1113
productionUrl: string;
1214
secret: string | undefined;
1315

1416
discordClientId: string;
1517
discordClientSecret: string;
18+
extraPlugins?: TExtraPlugins;
1619
}) {
1720
const config = {
1821
database: drizzleAdapter(db, {
@@ -25,6 +28,7 @@ export function initAuth(options: {
2528
productionURL: options.productionUrl,
2629
}),
2730
expo(),
31+
...(options.extraPlugins ?? []),
2832
],
2933
socialProviders: {
3034
discord: {

0 commit comments

Comments
 (0)