boolean | objectundefinedConfiguration to enable the application’s SSG (Static Site Generation) feature.
This configuration takes effect only when SSG is enabled. Please read the Static Site Generation documentation to understand how to enable SSG and its use cases.
The SSG feature is closely related to routing. It is recommended to understand the routing solution before using SSG.
output.ssg for single-entry apps.output.ssgByEntries.output.ssg is true and output.ssgByEntries is not set, all routes under all entries are treated as SSG routes.When this configuration is set to true, the SSG feature will be enabled for all entries by default. For manual routing, the root route of the entry will be rendered. For conventional routing, each route in the entry will be rendered.
export default defineConfig({
output: {
ssg: true,
},
});When the value type is Object, the following attributes can be configured.
type SSGRouteOptions =
| string
| {
url: string;
headers?: Record<string, any>;
};
type SSGOptions = {
headers?: Record<string, any>;
routes?: SSGRouteOptions[];
};In the example configuration below, SSG will render the pages corresponding to the /, /about, and /user/:id routes.
For the /user/:id route, cookies will be added to the request headers.
export default defineConfig({
output: {
ssg: {
routes: [
'/',
'/about',
{
url: '/user/modernjs',
headers: {
cookies: 'name=modernjs',
},
},
],
},
},
});