#Is there a way to check whether a route is dynamic or static?
1 messages · Page 1 of 1 (latest)
Hi @lyric sail. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
In Next.js, a route can be either statically or dynamically rendered.
- A static route is one where components are rendered on the server at build time. The result of the work is cached and reused on subsequent requests.
- A dynamic route is one where components are rendered on the server at request time.
However, the Next.js framework does not provide a direct function to check whether a route is static or dynamic. The type of rendering is determined by how you've set up your data fetching and the use of dynamic functions in your route.
Here's a summary of how data fetching and dynamic functions affect the rendering behavior of a route:
| Data Fetching | Dynamic Functions | Rendering |
|---|---|---|
| Static (Cached) | No | Static |
| Static (Cached) | Yes | Dynamic |
| Not Cached | No | Dynamic |
| Not Cached | Yes | Dynamic |
Dynamic functions always opt the route into dynamic rendering, regardless of whether the data fetching is cached or not. In other words, static rendering is dependent not only on the data fetching behavior, but also on the dynamic functions used in the route.