Next.js Discord

Discord Forum

main route served as SSG

Unanswered
Asian black bear posted this in #help-forum
Open in Discord
Asian black bearOP
guys does next in latest version makes routes by default served as SSR , cuz before I had my main route that has just some static ui with no route segments when i run built the app i saw that it was SSR though it should of been SSG , I turn it back to SSG using
export const dynamic = "force-static"
but i just wanna know if the default behaviour changed

31 Replies

@DirtyCajunRice | AppDir default behavior hasnt changed
Asian black bearOP
Okay thanks ! but What do you think would turn a page that have nothing but some static ui turn into SSR ??
@DirtyCajunRice | AppDir impossible to say without lookin at the code
Asian black bearOP
@Asian black bear Click to see attachment
Asian black bearOP
that's the main route im naming it Home
@Asian black bear that's the main route im naming it Home
if there are any searchParams, any cookies, or header requests, any ANYTHING that takes runtime info it would trigger it
@DirtyCajunRice | AppDir if there are any searchParams, any cookies, or header requests, any ANYTHING that takes runtime info it would trigger it
Asian black bearOP
I have searchParams but not in this route so it shouldnt affect it as far as i know , the only thing which the ProductsGuide component is a server component cuz i create a blurDataUrl for some images there but that shouldnt turn the whole route to SSR i guess
@DirtyCajunRice | AppDir it all depends on how high up it is in the segment
Asian black bearOP
can u explain more pls ?
@Asian black bear can u explain more pls ?
if you have something dynamic at root level, everything below it is dynamic. if its dynamic at /foo, then /foo/bar and /foo/bar/baz will be too
@DirtyCajunRice | AppDir if you have something dynamic at root level, everything below it is dynamic. if its dynamic at /foo, then /foo/bar and /foo/bar/baz will be too
Asian black bearOP
aaah got it , but this is literally the first route (page) there's nothing before it that might change it to dynamic
if not, doesnt hurt to make a reproduction repo and post to github. may have found a weird bug
@DirtyCajunRice | AppDir not in any of those imported components nor in layout?
Asian black bearOP
this is the layout
Where is your html and body tag in root layout?
Tbh it’ll be much easier to make it a GitHub repo and let us read the code
Asian black bearOP
@fuma Where is your html and body tag in root layout?
Asian black bearOP
m using route groups thats why I have more than one layout , the layout u saw is not the root layout
@Asian black bear its your clerk provider
1, it needs to go after html
2. its client so its dynamic
@DirtyCajunRice | AppDir 1, it needs to go after html
Asian black bearOP
what does this mean pls ?
@Asian black bear what does this mean pls ?
you have
 <ClarkProvider>
   <html>

you need
  <html>
    <ClarkProvider>
@DirtyCajunRice | AppDir you have js <ClarkProvider> <html> you need js <html> <ClarkProvider>
Asian black bearOP
Aaah got u , is this what made that route turn to SSR ?
@Asian black bear Aaah got u , is this what made that route turn to SSR ?
no thats just bad practice you have done. The clerk provider itself is what made it dynamic.
the provider is client side, and therefore needs dynamic data
@DirtyCajunRice | AppDir the provider is client side, and therefore needs dynamic data
Asian black bearOP
Okay so this will make all my routes dynamic , but I still have the ability to turn some specific routes to static using the route segments init?
@Asian black bear Okay so this will make all my routes dynamic , but I still have the ability to turn some specific routes to static using the route segments init?
you can force any route you want to be static. Just be aware that if it needs dynamic data from clerk it will probably not function as expected
Asian black bearOP
okay man I appreciate it , ty for your time and help
np
@DirtyCajunRice | AppDir <@728274568204255273> its your clerk provider
@Asian black bear can you mark this one as the answer please