Next.js Discord

Discord Forum

Where are the static pages stored (app router)?

Unanswered
Snowshoe posted this in #help-forum
Open in Discord
SnowshoeOP
With pages router, there was a folder with all the static pages in, but I can't find anything similar with app router. The problem I have, is that while Next says it is generating static pages on build, when I view the static page, its behaviour suggests it's calling the database for the data again.

4 Replies

@Snowshoe With pages router, there was a folder with all the static pages in, but I can't find anything similar with app router. The problem I have, is that while Next says it is generating static pages on build, when I view the static page, its behaviour suggests it's calling the database for the data again.
When you using „force-static“ to make sure they are statically rendered, keep in mind, that you also need to add „generateStaticParams“ to generate them during build time.

When you done both the files will be in the .next folder in the folder „static“
SnowshoeOP
yes, using - export const dynamic = "force-static";
when it builds, you can see it doing generateStaticParams for all the pages, but then nothing in the static folder, see attachment.

The following should be static??
├ ● /sites/[...slugs] 1.56 kB 1.07 MB
├ ├ /sites/myapp/blog
├ ├ /sites/myapp
├ ├ /sites/myapp/services/technical-consulting
├ └ [+614 more paths]
SnowshoeOP
ok, I've just figured it out. In my case, I need both:
export const dynamic = "force-static";
AND
export const dynamicParams = true;

then it generates SSG pages (not static) in the /server/app/sites/ folder

the build process reports:

├ ● /sites/[...slugs] 1.56 kB 1.07 MB
├ ├ /sites/myapp/blog
├ ├ /sites/myapp
├ ├ /sites/myapp/services/technical-consulting
├ └ [+614 more paths]

○ (Static) prerendered as static content
● (SSG) prerendered as static HTML (uses getStaticProps)
ƒ (Dynamic) server-rendered on demand

it's now behaving as expected!

to my mind the docs aren't too clear in this as I can't see anywhere that states both these commands have to be in place, unless my setup is unusual?