@@ -15,7 +15,16 @@ export const packageManagers = {
1515 yarn : "yarn add @nextlytics/core" ,
1616} as const ;
1717
18- const defaultAuthImport = 'import { auth } from "./lib/auth"; // next-auth' ;
18+ const defaultAuthImport = [
19+ "// Nextlytics runs in Edge middleware, so it can't import your main auth.ts" ,
20+ "// if it pulls in Prisma, nodemailer, or other Node.js-only deps." ,
21+ "// Create a lightweight auth instance from your edge-safe base config." ,
22+ "// See: https://authjs.dev/guides/edge-compatibility" ,
23+ 'import NextAuth from "next-auth";' ,
24+ 'import authConfig from "./auth.config";' ,
25+ "" ,
26+ "const { auth } = NextAuth(authConfig);" ,
27+ ] . join ( "\n" ) ;
1928const defaultAuthCallback = [
2029 " async getUser() {" ,
2130 " const session = await auth();" ,
@@ -44,7 +53,6 @@ export function configSnippet(opts: ConfigSnippetOptions): string {
4453 "// src/nextlytics.ts" ,
4554 'import { Nextlytics } from "@nextlytics/core/server";' ,
4655 opts . backendImport ,
47- "// Optional: import your auth library to track authenticated users" ,
4856 authImport ,
4957 "" ,
5058 "export const { middleware, analytics } = Nextlytics({" ,
0 commit comments