Configurable Netlify builds chain

Hi All, Since pre-rendering is a hot topic right now I would love to ask for the feature to have control over the deployment chain, so that during my application build I can reference freshly deployed functions. Currently functions deploy at the end after my application build, so all I can do is to reference live functions.

I got inspired by Smashing Magazine solution from JAMstack ebook:

“Smashing Magazine’s JAMstack site: each time a user comments on an article, a simple function commits the comment to the site’s repository and triggers a new build (as long the comment passes moderation).”

-Excerpt From: Mathias Biilmann and Phil Hawksworth. “Modern Web Development on the JAMstack”. Apple Books.

Here is my desired chain:

  1. Trigger deploy
  2. Functions deploy first, making them exposed to the app build
  3. During application build, I pre-render all the content fetching data from above functions, simple GET methods in each app route.
  4. My app goes live with pre-rendered data so there is no need to fetch it again during runtime.

and I guess the chain could be configurable in netlify.toml file :thinking: All the logic of pre-rendering is of course on me. All I wish is to have those functions exposed during the app build. Smashing Magazine’s approach is a little different, since they commit new change to the repo, but I think above workflow could be next level of that approach and everything would be cooking on the fly.

We can and will enter feature request for this but it isn’t possible currently.

You can workaround this limitation with a monorepo and connecting the repo two two different sites. One site for only the functions used during the site build and the other site for the site itself.

So there are two sites:

  • a “functions site” which only has the functions used for the site build
  • a “site site”

The workflow would look something like this:

  1. commit changes to the functions which are only part of the “functions site”
  • this doesn’t trigger a build on the “site site” due to the build.ignore setting
  • this can be updated independently of the “site site”
  1. When the “functions site” build is complete it calls, the webhook on the other to build the “site site”.
  • this then uses the updated “functions site” to build the “site site”

This is a little “kludgey” but it would enable the functions update then site build workflow now while the feature request is pending.

There is a caveat. If the commit updates both the “functions site” and the “site site”, both will be built in parallel (depending on the account type - Pro or higher).

​Please let us know if there are questions about this workflow above and/or if you would still like file this as a feature request.