DEV Community

Diego Eis
Diego Eis

Posted on

Good practices for JAMStack projects

The revolution of websites using an architecture based on JavaScript, APIs and a pre-generated code is called JAMStack. This way to do websites have the objective to relieve the architecture to maintain websites or systems. Take my website for example In there we had maintained an architecture based on Wordpress, this means that we need to have a MySQL database... basically a LAMP architecture. In this way, for sake of organization, we maintain this architecture in two different droplets in DigitalOcean. Today we take off the Wordpress and the Website is all made using Hugo, hosted in Netlify, with the code on Github.

This is not a hard thing to do, but exist some good practices that you can follow to make easy your way.


This is not a required (by the way, none of these topics is), but behind your website is already very light due to the loading of pure static HTML files, it could be improved if we use a CDN. The projects based in JAMStack don't need to server-side code or something like that, they could be distributed more easily.

The most popular CDN is CloudFlare, but there exist a lot of other services that you can put your assets in there, but usually, they already give the most popular JavaScript frameworks and libraries to you use in your projects. Some links:

All the code live in GIT

This is life rule. Today is not normal to see teams that don't use some kind of code version service. The GIT is the most popular and we know a bunch of services like GitHub that make all the hard job to us. In JAMStack projects, anyone needs to download and rune the code on your own machine in minutes. Install databases in many environments, run up the dependencies and so on is not needed. The simplicity of the static stack reduces to almost zero the friction of contributing to projects based on the JAMStack idea, plus we make simple the test and staging workflows.

Build tools

Depending on the project, it is interesting to use a build tool. The idea is that all the process need to be automated. The result will be static HTML, CSS and JS files, but it need be built following the good practices. You can use all that good stuff: pre/post CSS processors, use WebPacks and regulars task runners like Gulp, Grunt, Babel and whatever you like to use to make your build life easier.

Here we basically use only SASS to deliver the CSS and nothing more. We don't have a lot of JS that we need to minify the code. The images are hosted in imgur. The static files generation is made by Hugo. So, I dismiss anything that could bring more complexity to the project. Today, we have more than 1800 articles and posts to build. This takes 5 minutes to build in production, using Netlify.

Automated Builds

Because the JAMStack project is made with pre built code, when we change the content or the interface, this updates will not go to the product until you run the build process. When you upload new code to your repository, your environment needs to know that, to make the build of files and publish automatically your project. I know that exist many services to do that, but all them are more complex exactly because most regular projects depends on some kind back-end language. In a simple JAMStack website, you can make your own webhooks or use some service that gives this feature to you, like Netlify.

Atomic Deploys

Atomic Deploys are deployed where all the system just go to production when the upload of all modified files is ended. It is common to make several changes, either content or interface, needing to make deploys of several files. Until you upload each of the files, there may be a time of inconsistencies until the upload process is finished.

Imagine that: the new HTML code was uploaded first than the CSS, in a brief moment, the layout will break. This can happen all the time depending on the frequency you make changes.

Cache invalidation

We are talking about static files. It is common to have problems with the cache. Cache is the bad and good things of the web. In this case, we have to be sure that the environment is invalidating the cache, especially if we are using a CDN. You need to be sure that the browsers will download the new files.

The Netlify (no, the Netlify is not paying me to say all that) has a feature called Instant Cache Invalidation, that invalidate the old cache without any work.


A lot of what I said are things that we make in our regular days. But, usually, we do that to make easy just a part of the project. But, I already knew teams where the front-ends need to build your assets before pushing the code because the existing workflow does not build this kind of file. When we talk about a project that has light architecture like the JAMStack propose, we can't add manual tasks, but, we can not automate everything to the point of making the project complex.

Obviously, a JAMStack project cannot be compared with complex systems. I'm talking about most websites the live on the internet. Personal little blogs, personal websites, company institutional websites, etc... Here in Brazil, I've seen discussions in companies that want to make their websites using React. What the point here? We need to learn to use the right tool to the right problem. Start small. During a long time, the first answer when we need to create a website was "Use Wordpress". But the technology to make websites already exist a long time before, it is called HTML.

Top comments (4)

philhawksworth profile image
Phil Hawksworth

Nice post Diego!

The use of a CDN is a good aspect to call out and it can be a somewhat intimidating prospect. There is a lot of complexity involved in correctly configuring a CDN. Particularly if your site will change regularly (code, content, design, assets).

Since you talk a bit about CDNs, I'd just add that Netlify also provide a CDN for JAMstack sites. This is actually core to the service. It's just that as a developer you are protected from needing to configure it manually or worry about it. (Although you have quite a bit of control should you choose to explore that)

polite disclaimer: I work at Netlify, so while you weren't paid by Netlify for your kind comments, people might just expect it from me. :)

diegoeis profile image
Diego Eis

Hey! :-D

I use Netlify today exactly because I don't have to do a lot of work to have a simple project online.

Thank you for comment and continue with the good work. :-D

javierpomachagua profile image
Javier Pomachagua

Nice post!
I have readed about JAMStack sites but i have a question.
I want to build a blog with Nuxt (static), when the admin user post a blog I have to use a webhook to build again the frontend for getting new changes in my database. Am I correct? What if I have two admin posting blog? Do I have 2 webhooks running same?
Sorry but I am new in JAMStack. TY!

tailomateus profile image
Tailo Mateus Gonsalves

Nice \0/