Build: prerendered as static HTML (uses getStaticProps)
Answered
British Shorthair posted this in #help-forum
British ShorthairOP
I am utilizing the app router in my Next.js application.
After the build process, I receive the following message: 'â— (SSG) prerendered as static HTML (uses getStaticProps). This should be the case for pages inside app/dashboard/[search_id]/[data].' However, when I inspect the build folder at .next/server/app/dashboard/[search_id]/[data], I cannot find any HTML files there.
The page in question is making use of the 'generateStaticParams' function.
Can somone please help me understand why the HTML files are not present in the build folder for this page?
After the build process, I receive the following message: 'â— (SSG) prerendered as static HTML (uses getStaticProps). This should be the case for pages inside app/dashboard/[search_id]/[data].' However, when I inspect the build folder at .next/server/app/dashboard/[search_id]/[data], I cannot find any HTML files there.
The page in question is making use of the 'generateStaticParams' function.
Can somone please help me understand why the HTML files are not present in the build folder for this page?
Answered by Ray
so you need this if you want the page static generate
export const dynamic = 'force-static'30 Replies
if not, the html file will be generated when the route being visited
British ShorthairOP
No with generateStaticParams, but thats the way for the app router right?
@British Shorthair No with generateStaticParams, but thats the way for the app router right?
oh I thought you were talking about page router
so you build the page with
generateStaticParams?British ShorthairOP
Yes ind
British ShorthairOP
I do have an error in production, checking the logs now.
British ShorthairOP
Okay I made a typo, now its working in production. The build is also showing the pages now. However the build is now showing empty folders. This should be html files right?
British ShorthairOP
No they're empty
also empty inside the [search_id] folder?
British ShorthairOP
look like your page is dynamic
do you use any of these function on the page?
cookies(), headers()?or fetch with
no-storeyou could force the page static generate by this
export const dynamic = 'force-static'British ShorthairOP
I am retrieving some data from a s3 bucket.
export async function getData(key: string) {
const params = {
Bucket: 'BUCKET',
Key: key
};
try {
const command = new GetObjectCommand(params);
const data = await s3Client.send(command);
if (!data.Body) return;
const bodyContents = await streamToString(data.Body as Readable);
return JSON.parse(bodyContents);
} catch (err) {
console.error('Error fetching S3 object:', err);
throw err;
}
}
And I am making a call to a supabase DB. There I use a client initiliazed with
import { Database } from '@/types_db';
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';
const supabaseServer = () => {
cookies().getAll();
return createServerComponentClient<Database>({ cookies });
};
export default supabaseServer;
Maybe that client is making the page go dynamic?
export async function getData(key: string) {
const params = {
Bucket: 'BUCKET',
Key: key
};
try {
const command = new GetObjectCommand(params);
const data = await s3Client.send(command);
if (!data.Body) return;
const bodyContents = await streamToString(data.Body as Readable);
return JSON.parse(bodyContents);
} catch (err) {
console.error('Error fetching S3 object:', err);
throw err;
}
}
And I am making a call to a supabase DB. There I use a client initiliazed with
import { Database } from '@/types_db';
import { createServerComponentClient } from '@supabase/auth-helpers-nextjs';
import { cookies } from 'next/headers';
const supabaseServer = () => {
cookies().getAll();
return createServerComponentClient<Database>({ cookies });
};
export default supabaseServer;
Maybe that client is making the page go dynamic?
British ShorthairOP
Yeah I see
so you need this if you want the page static generate
export const dynamic = 'force-static'Answer
British ShorthairOP
But I first have to remove the cookies right?
@British Shorthair But I first have to remove the cookies right?
your client work without cookies?
I think you could leave it there
British ShorthairOP
Yes you are right, now its working
Thanks!
no prob