Next 14.1.4, every route is considered dynamic on next build
Unanswered
Eulophid wasp posted this in #help-forum
Eulophid waspOP
Why is every single route dynamic even ones that are server components and literally no imports and just some text ?
16 Replies
@Eulophid wasp Why is every single route dynamic even ones that are server components and literally no imports and just some text ?
if a layout is dynamic, every page using that layout is also dynamic. that is probably what's happening here
@joulev if a layout is dynamic, every page using that layout is also dynamic. that is probably what's happening here
Eulophid waspOP
I do have a layout where i use an authentication provider, it is probably dynamic. Can i force routes withing to be static ?
@Eulophid wasp I do have a layout where i use an authentication provider, it is probably dynamic. Can i force routes withing to be static ?
you can manually cache queries in the page with unstable_cache() or fetch(), then the page itself will still be dynamic but the slow part of the page is already cached so the page is effectively static
@joulev you can manually cache queries in the page with unstable_cache() or fetch(), then the page itself will still be dynamic but the slow part of the page is already cached so the page is effectively static
Eulophid waspOP
there arent any queries on those routes, they are just part of a dynamic layout. Is it possible to use something like force static on each of those routes ?
@Eulophid wasp there arent any queries on those routes, they are just part of a dynamic layout. Is it possible to use something like force static on each of those routes ?
no you can't. if there aren't any queries on those routes, there is nothing you need to do because the route is already as fast as it can possibly get already
@joulev no you can't. if there aren't any queries on those routes, there is nothing you need to do because the route is already as fast as it can possibly get already
Eulophid waspOP
export const dynamic = "force-static";
i tried to use this on top and the next build output showed that this page became static instead of dynamic. Any side effects here ?
i tried to use this on top and the next build output showed that this page became static instead of dynamic. Any side effects here ?
@joulev the auth part in your layout most likely broke
Eulophid waspOP
why ?
i did this on a route and not on the main layout
@Eulophid wasp i did this on a route and not on the main layout
yes but then the layout will also inherit this force-static, if i recall correctly. well there is only one way to know... test it out, if it works it works
the only thing at risk of breaking is the dynamic part of the layout, if it still works then that's great news
Eulophid waspOP
okay. i will test it out, even though a parent getting affected by a child would be a bit weird, should be the other way around
to my knowledge it is not possible to have a static page in a dynamic layout. the layout can be static in some pages and dynamic in others, but you cannot have part of the resulting html dynamic and part of it static, on a single route. assuming no PPR.
@joulev to my knowledge it is not possible to have a static page in a dynamic layout. the layout can be static in some pages and dynamic in others, but you cannot have part of the resulting html dynamic and part of it static, on a single route. assuming no PPR.
Eulophid waspOP
hmm, i know its not possible within the same route, not layout
ill try anyway
thank you