Pre-rendering
Zuby.js will try to pre-render pages based on configured output mode.
- In the
static
output mode, all pages with static route will be pre-rendered by default. - In the
server
output mode, only pages withprerender
property set totrue
will be pre-rendered.
Page level pre-rendering
You can also enable/disable the pre-rendering for the specific page by exporting the prerender
property with true/false
value.
Example:
It can be also defined as a function that returns a boolean value.
Dynamic routes can be pre-rendered as well,
however you need to export the prerenderPaths
property with an array of dynamic params that should be used to construct the paths
or the full path itself that should be pre-rendered. This pattern is very similar to the getStaticPaths
function of Next.js or Astro.
Global pre-rendering
Zuby.js also allows you to define all paths that should be pre-rendered in the zuby.config.mjs
file
by using the prerenderPaths
property.
These paths don’t need to be pages but can be also API endpoints or any other response returned by the handler.
They can be also generated dynamically based on the data from the API.
See the config options section for more details.