#Static Auth Routes

1 messages · Page 1 of 1 (latest)

dusky marsh
#

Is there a way to maintain having static routes on auth pages without using partial pre-rendering and middleware checks?

steady frostBOT
#

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:

  1. 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).

  2. 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).

  3. In the App Router, you can use the config.dynamicParams property to control how params outside of generateStaticParams are handled. This replaces the fallback option from getStaticPaths in the Pages Router Next.js Docs - Replacing fallback (https://nextjs.org/docs/app/building-your-application/upgrading/app-router-migration#replacing-fallback).

  4. 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.

#

If you need a more specific solution for your use case, you might want to consider the trade-offs between static generation and dynamic rendering for auth pages, or explore the middleware and partial pre-rendering options recommended by Next.js.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: