Static Site Generation (SSG) / Pre-rendering
See original GitHub issueIs your feature request related to a problem?
no
Describe the solution you’d like
There should be a command, maybe something like vite build --mode ssg
to generate the application or website pages as prerendered, resumable html files alongside the client js files.
Describe alternatives you’ve considered
Additional context
So far I came up with this basic working solution (for a single page), although I am sure it does not work for all options/settings:
// /build-ssg.mjs
const fs = await import('node:fs/promises'); // currently only works with node.js
const server = await import("./server/entry.ssr.js");
const routes = [{url: "/", outFile: 'dist/index.html'}]; // should be derived from router or provided by developer
for (const route of routes) {
const { html } = await server.render({ url: route.url });
await fs.writeFile(route.outFile, html);
}
It relies on the client- and sever-build being generated. It would be smoother if in the end the server part was not necessary to be under server/entry.ssr.js
, I think most users would not want SSR and SSG eventually.
Maybe something like this can be integrated into qwik directly. @manucorporat any opinions?
Issue Analytics
- State:
- Created a year ago
- Reactions:6
- Comments:9 (8 by maintainers)
Top Results From Across the Web
Static Site Generation (SSG) Overview - Qwik - Builder.io
Static Site Generation, or commonly referred to as "SSG", is the process of pre-rendering site webpages into static HTML files. The benefit is...
Read more >Basic Features: Pages - Next.js
Next.js has two forms of pre-rendering: Static Generation and Server-side Rendering. The difference is in when it generates the HTML for a page....
Read more >Static Site Generation - Stencil.js
Static Site Generation (SSG) means building and rendering components and routes at build time (aka prerendering) rather than server request time (SSR) or...
Read more >What the heck is SSG: Static site generation explained with ...
Static Site Generation a.k.a. SSG is pre-rendering your React app into HTML at build time. SSGvsSSRvsCSR. Let's break it down.
Read more >Differences Between Static Generated Sites And Server-Side ...
Statically generated sites or pre-rendering and server-side ... A static-site generator (SSG) is a software application that creates HTML ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Implemented already!
@nnelgxorz I agree, this is state-of-the-art pre-rendering! 11ty’s Serverless plugin supports three render modes:
We basically have to build the SSR server and client bundles at build time via the
optimizer/qwikVite
. Then we can invoke it during the build to generate html pages at build time. For this we need some smart analysis of all available (static or dynamic) routes from the router or a list of routes the developer wants to pre-render.At runtime, the server has to handle each request accordingly. The current SSR server only renders each page on each request and serves that html. There we would have to add some logic to:
routeRenderMode(...)
Other features a SSG/Prerender plugin could have:
routeRenderMode
implemented insrc/entry.ssg.tsx
function routeRenderMode(url: string, routes: QwikCityRouterData): 'pre-rendered' | 'on-demand' | 'dynamic'
qwik-ssg build --ssg src/entry.ssg.tsx
Anyways these are just some ideas.
@manucorporat Is there a way to “ask” QwikCity for the configures routes, including dynamic ones?