I'm Justin, a full stack developer

I'm Justin Paelmo, a full stack developer

Guide: netlify and strapi cloud webhooks

published

So I solved an issue I created to begin with

You know, the perpetual job security of a web developer solely stems from the process of engineering.

As I reflected in figuring out that I needed to how to write blog content Static Site Generation (SSG) vs Server Side Rendering (SSR) we're just sort of going in circles. The SSR of today was the PHP of yesterday. In my opinion there is one main caveat from to why PHP (and other similar backend languages) from back then had a superior workflow: deployment.

As long as PHP is running on your server, and Apache is properly set up then a user going to your domain is served a website based on the code present on the server. This of course comes with its ups and downs but if you really wanted to get a website up without any overhead you could just SFTP some .html files to your server and everything would "just work".

Unfortunately while SSG shares some ideology for deployment, it has its own pitfalls.

Basically, updating my website became my biggest bottleneck.

It was faster for me to see updates on my site by pushing minor updates to the git repo. Any time I created an entry would mean double the work to have it updated live.

So whats the solution? webhooks

Strapi and Netlify both have webhook interfaces. Strapi can specifically send a request and Netlify has a wonderfully simple "Goto this Endpoint" implementation.

Netlify's end

netlify's UX for adding a webhook entrypoi t This is just beautifully simple. You pick the branch that will be built when POST is sent to the URL. That's it.

Here's the basic UI for strapi's side:

Strapi's webhook UI

Creating a new webhook from Strapi's end basically will send a POST request to a provided URL. The webhook will send Event data related to what was done through strapi to trigger the webhook.

What's really nice from strapi's end is that you get to pick and choose when your webhook is fired. strapi event selection

Because of the nature of content writing (and the speed at which I wanted to update my portfolio) triggering builds upon CREATE was not necessary.

That's it. That's the solution.

I write content to my backend. Strapi sends out a POST request to netlify and netilfy processes the build. My site gets updated and I don't have to push to my github repo to see the changes.

Honestly, this wasn't even that hard I don't even need to sleep on it.