#Static Auth Routes
1 messages · Page 1 of 1 (latest)
Hi @dusky marsh. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
Based on the knowledge sources provided, there doesn't seem to be a straightforward way to maintain static routes on auth pages without using partial pre-rendering and middleware checks in Next.js. However, I can provide some relevant information about static generation and authentication in Next.js:
-
Next.js recommends against doing auth checks in layouts. Instead, they suggest using optimistic checks in Middleware and secure checks in a data access layer Github Issue Comment (https://github.com/vercel/next.js/issues/43704).
-
For authentication scenarios, Next.js provides a Preview Mode feature that allows you to temporarily bypass static generation and render pages at request time instead of build time Next.js Docs - Preview Mode (https://nextjs.org/docs/pages/building-your-application/data-fetching/get-static-props#preview-mode).
-
In the App Router, you can use the
config.dynamicParamsproperty to control how params outside ofgenerateStaticParamsare handled. This replaces thefallbackoption fromgetStaticPathsin the Pages Router Next.js Docs - Replacing fallback (https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#replacing-fallback). -
You can opt out of the Full Route Cache and dynamically render components for every incoming request by using Dynamic APIs, setting
dynamic = 'force-dynamic', or opting out of the Data Cache Next.js Docs - Opting out of Caching (https://nextjs.org/docs/app/building-your-application/caching#opting-out-2).
However, these approaches generally involve some form of dynamic rendering or middleware checks. The knowledge sources don't provide a clear method to maintain fully static auth routes without using partial pre-rendering or middleware checks.