I recently wrote up an experiment on CSS-Tricks which goes into some detail about this technique. The intention is to use a serverless functions to perform a server-side serverless(!) render of a page as a custom 404 handler.
This is useful if you are generating your site from content in a decoupled content management system or database. Or if you are gathering and serving user generated content. I’m collecting content from users via a form, and storing it in a database with FaunaDB.
The result gives you:
- a static/pre-generated site
- instant access to new pages created from user contributions
- serverless render as a fallback via 404
- no client-side rendering or js dependencies.
The example site is here:
The code is all open source and available to explore here:
And the detailed explanation and walkthrough is on css-tricks here: