Static vs Dynamic Rendering
📓 Note:
It's noteworthy that there are various ways to get from static to dynamic rendering. We have seen two of these ways:
- Every dynamic route is rendered on demand and thus dynamic by default.
- Every static route that uses
"force-dynamic"
as a configuration is rendered on demand too.
However, there are more ways to opt-in dynamic rendering for a route in Next.js, which are mainly coupled to using built-in features of the framework that require dynamic rendering by their nature:
cookies().set();
cookies().delete();
headers();
searchParams
useSearchParams();
noStore();
The last one is even preferred over "force-dynamic"
as it is more granular and can be used on a per-component basis.
📘 Exercises
- 📚 Read more
Learn about static and dynamic rendering in Next.js.
8 comments