SSG with dynamic route parameters #6958
-
From the docs it's not quite clear if I can use SSG with dynamic route parameters that need to be fetched from a DB at build time. Is it possible? Example shows values hard-coded in the config. But what if I need to fetch a list of blog post ids from CMS? Something to replicate generateStaticParams from Next.js |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Modern.js not support the API like generateStaticParams. And we will consider the topic in next quarter. Now we can use dynamic ssg route like: export default defineConfig(async (env) => {
const data = fetchCMSData();
const ssgRoutes = genSSGRoutes(data);
return {
output: {
ssg: {
routes: ssgRoutes,
},
},
plugins: [appTools({ bundler: 'rspack' })],
};
});
This configuration will generate two ssg routes, which handle |
Beta Was this translation helpful? Give feedback.
Modern.js not support the API like generateStaticParams. And we will consider the topic in next quarter.
Now we can use dynamic ssg route like:
modern.config.ts
can run async function, so we can fetch data in this file. And we can use data to generate ssg routes:This configuration will generate two …