Today we’re excited to announce On-demand Builders, a new solution to improve build times for large sites on Netlify. Along with the proposal for Distributed Persistent Rendering (DPR), this release represents the first step forward in a significant evolution of the Jamstack architecture to support larger websites and faster development cycles—across any JavaScript framework.
On-demand Builders are serverless functions used to generate web content on-demand that is automatically cached on Netlify’s Edge CDN. They enable you to build the pages for your site when a user visits them for the first time and cache them at the edge for subsequent visits.
To learn more, read the blogpost or visit our docs. We’d love to hear your feedback!
3 Likes
Hey there, @lisatjide
All frameworks can use On-demand Builders. Thanks for checking!
How will onPostBuild hooks work, for plugins?
I can understand how the name “On-demand Builders” could mean that we’re making the entire Netlify build system available in a serverless function. However, that’s not the case. Builders are serverless JavaScript functions that you write yourself, or that framework or plugin creators might choose to provide.
Since On-demand Builders use a JavaScript runtime, it’s possible to use any JavaScript framework with them. But frameworks / site generators / build tools that run in other languages won’t work.
@lisatjide, because Jekyll requires Ruby, you can’t run it in an On-demand Builder. There may be other ways to take your Jekyll templates and content and compile them to a built page in JavaScript, but as far as I know there aren’t any pre-built tools for that.
@marcellothearcane Because Build Plugins and the onPostBuild
event handler rely on the Netlify build system, they can’t be used in On-Demand Builders. However, the main purpose of having an event like onPostBuild
is to have an access point in a build process that you don’t control. In your own builder function, you control the whole thing. So if you want to run some code after the page is built, you can write your function to do that. And if you want it to do the same thing that a particular plugin does, you might be able to take the plugin code and adapt it to do the same thing in your function (since plugins are open source and written in JavaScript).
I’ll admit, though, coding your own multi-step On-Demand Builder function is not as easy as clicking a button to install a plugin and having it do its thing. In the end, the most featureful way to build site pages and assets is in Netlify’s regular build & deploy lifecycle. If your site isn’t huge, that’s usually what works best. It’s more when you get into really, really large scale that you would consider the trade-offs of deferring some pages to build later with an On-Demand Builder.
3 Likes
Thanks for your reply! I ask, because I wrote a plugin (netlify-plugin-csp-generator), and was wondering what I’ll need to change in order to support on-demand builders.
If I understand correctly, it may be possible to make a separate ‘plugin’ that could be used by an on-demand builder, kind of like how Express handles middleware - does that sound right? Though I expect there’ll be time limits like your edge handlers, so that might not always be feasible.
I’ll just say ‘not supported’ for the time being, and see if there is any demand in the future. It’s not like my plugin is widely used!
2 Likes
Ah, good question, @marcellothearcane! The does seem like a tricky one, especially because the _headers
file wouldn’t do anything by the time an On-demand Builder runs, either.
2 Likes