Static Site Generation
Solara's static site generation (SSG) feature allows you to pre-render HTML for your website, improving the user experience by providing quick page loads. When a user requests a page, the pre-rendered HTML is served directly to the user. After the page is displayed, the Solara server will connect and take over rendering to make the page interactive.
Using SSG is mostly useful when the content of your website is the same for all users. This is the case for this page (the Solara page itself).
Benefits of SSG
Another benefit of using SSG is improved search engine optimization (SEO). By allowing web crawlers to index your pages, you can improve the visibility of your website in search engine results.
In addition to improving SEO, using SSG can also help with indexing your pages and making them more easily discoverable by users.
Using Solara's SSG feature.
$ pip solara-enterprise[ssg] $ playwright install
Using the command
$ solara ssg your.awesome.app
Will run the solara server and use playwright to fetch all known pages and save them to the
../build directory. Solara knows about your pages because of its routing support.
All HTML files in the
../build will be used to pre-populate the HTML served to the user.
For fast and simpler deployment, you can also add the
--ssg flag to the
solara run command, e.g.:
$ solara run our.awesome.app --ssg
This will start you server immediately, and start a thread in the background that will fetch the known pages and put the in the
../build directory, similar to the pre-deployment procedure.
The downsides of this method, is that users or crawlers may request a page when SSR is not done yet, leading to a slower page load or missing content for the crawler.
SOLARA_SSG_BUILD_PATH: Override the directory where there html pages are stored.
SOLARA_SSG_ENABLED: Alternative to passing the
--ssgflag. Should be used when running solara without
solara run(e.g. using gunicorn/uvicorn).
SOLARA_SSG_HEADED: Run playwright using
headedmode (in contrast to
headless). Useful for debugging.