Enhancement to NextJS Demo Apps
Both the NextJS Page Router Demo App and the NextJS App Router Demo App now use version 3.1.0 of the nextjs-auth SDK. It demonstrates the new SDK auto-configuration capability. Now, only 3 fields are required when initializing the SDK in this demo app: wristbandApplicationVanityDomain
, clientId
, and clientSecret
.
Auto-Configuration in Edge Runtimes
While auto-configuration works well in Node.js runtime environments, manual configuration is strongly recommended when using Next.js Edge Runtime (Edge API Routes, Middleware, and Edge-rendered pages) due to the following limitations:
- Cold start latency: Auto-configuration requires an API call to the Wristband SDK Configuration Endpoint on every cold start, which can impact response times for authentication flows in Edge Runtime.
- No persistent memory: Edge Runtime instances don't maintain in-memory caches between requests, causing the SDK to refetch configuration data on every invocation.
For production Next.js applications using Edge Runtime, you can set
autoConfigureEnabled: false
and provide all required configuration values manually. This is especially critical for authentication middleware that runs on every protected route.
// Same for Page Router and App Router
import { createWristbandAuth } from '@wristband/nextjs-auth';
export const wristbandAuth = createWristbandAuth({
clientId: "--your-client-id--",
clientSecret: "--your-client-secret--",
wristbandApplicationVanityDomain: "auth.yourapp.io",
});