If you have ever tried to build a web app with Jamstack or you're new to the Jamstack ecosystem, In this article, we will take a look at some of the benefits of building with Jamstack alongside some of its unique features you should often use in your projects.
A lot has been previously written about Jamstack and its benefit on the Strapi blog, so we will briefly examine what Jamstack is before looking into the features.
Table of Contents:
- What is Jamstack?
- Strapi and the Jamstack
- The benefit of using Jamstack
- Top Features of Jamstack
What is Jamstack
According to the Jamstack community website Jamstack.org, the Jamstack can be defined as a modern way to build websites and apps that deliver better performance with a standard architecture based on prebuilt Markup, JavaScript, and reusable APIs.
The Jamstack acronym stands for Javascript, APIs, and Markup stack.
JavaScript
JavaScript in the Jamstack is a programming language used to develop all client-facing functionalities such as handling forms, performing API requests and response calls, etc. It is mostly used on the client-side, and examples are frontend frameworks like Angular, React, and Vue. e.t.c.
APIs
On the server-side, all database action and server-side functions are implemented with an API made available over HTTPS on the client-side. You can use an API-based headless CMS like Strapi to manage your content and present it to the client-side with an API.
Markup
Static site generators such as Gatsby, Next, Hugo, etc., are used to bundle and prebuild markup before deployment.
With this approach, markup incorporate javascript and is prebuilt into static assets, served to clients from a CDN, and relies on reusable APIs for its functionalities. This approach is designed to make the web faster, more secure, easier to scale, and most importantly, increase productivity.
Strapi and the Jamstack
Let say you're building a website or app with any of the static-site generators such as Gatsby, Next, etc., and you need to edit and maintain the content of your websites. You probably might want to use a headless CMS. That is where Strapi comes in among the many other headless CMS in the market today.
Strapi is a leading open-source headless CMS based on NodeJS used to build fast and easily manageable APIs. It enables you to seamlessly create and manage a content-rich experience exposed to any digital product, device, and service.
It free developers a lot of time while giving them the freedom to use their favorite development tools and frameworks. Strapi enables you to make flexible API structures easily with a beautiful user interface.
Strapi integrates smoothly with most static site generators. It enables developers to create digital content that extends through plugins. Strapi is a good choice for frontend developers who understand JavaScript.
The benefit of using Jamstack
Scalability
Jamstack sites are cached in a content delivery network compared to traditional websites that deal with heavy traffic loads by adding logic to cache popular views and resources. Because files are served through CDN, the CDN prioritizes higher traffic when there is so much request in your app. It enables built-in redundancy and incredible load capacity.
Security
Because Jamstack sites are served directly from a CDN and without a backend, you don't need to worry about server-side vulnerabilities because no code is run on the server to build pages, making it difficult to inject or attack your site.
Performance
The loading speeds of a page have a tremendous impact on user experience and conversion. With this in consideration, sites built with JamStack detach the need to generate page views on a server by generating pages ahead of time in a build.
Since CDN serves the pages, optimal high performance is possible without introducing expensive or complex infrastructure.
Cost Reduction
Building with the Jamstack approach drastically reduces software costs of the infrastructure and is easily maintainable. You don't need a team of experts to develop sites with the Jamstack, making it cheaper to scale, build and maintain.
Portability
Since sites built with Jamstack are pre-generated, it implies you can host your sites on several varieties of hosting services with a more remarkable ability to move them to any preferred host. Therefore any hosting solution should be able to serve a Jamstack site. This is a goodbye to infrastructure lock-in.
Better Developer Experience
Developing with Jamstack is simpler and easier to understand; the development process and maintenance are straightforward. You can build Jamstack sites with a wide variety of tools like Strapi.
They do not depend on sole technologies or little-known frameworks. Instead, they build on vastly accessible tools and conventions, making it easier to find talented developers with the skillset to build with Jamstack.
Coupled with the numerous options of CMS for site generation removes the need to maintain a separate stack for content and marketing.
Features of Jamstack
Automatic Builds with webhook
Because markups are prebuilt in Jamstack, any content changes won't go live until you run another build. That's is where webhooks with Strapi come in.
For instance, if you are building a website and using Strapi as your content management system and Netlify as your CDN, how do you automate this process when a new page is updated and notify Netlify that a new page has been published. You can create a webhook in Strapi to automatically deploy a modification on Netlify.
Atomic Deploys
As your web project gets more complex, new changes might require redeploying many files. Uploading these files can lead to an inconsistent state as the process ends.
Atomic deployment implies that changes don't go live until all modified files are uploaded. You can prevent this by a system that allows you to implement "atomic deploy." This medium ensures your site is always consistent with your visitors.
Instant cache invalidation
Compared to the traditional approach of building sites, one of the most important reasons for building modern sites the Jamstack way is that site can be hosted exclusively on a CDN(Content Delivery Network).
With instant cache invalidation from CDN services, it instantly goes live and pushes the changes to a global CDN when a build is uploaded.
It implies that you view your site instantly without timelessly waiting for changes when you update your website. This technique gives you a highly cached site that makes your site load ultra fast and immediately considers your updated changes.
Additionally, when choosing a CDN, try to make sure your CDN can handle instant cache purges.
Putting Everything on Git
Probably one of my favorite features when I started building the Jamstack site. Putting your site on Git provider enables a seamless level of collaboration and shipping for you and your team.
Anyone can git clone and install any needed dependencies with a standard procedure like npm install and instantly run the entire project locally without cloning any databases or any complex installation. This feature simplifies the staging and testing workflows while also reduces contributor friction.
Automating with Build Plugin
If you are building a project and you find yourself repeating the same thing on every project. You can automate the process by creating a plugin and reuse it whenever you need it. Let say you're building a modern JamStack project with a headless CMS like Strapi and with Netlify as your CDN.
Strapi has a unique plugin design pattern that enables you to create plugins injected into your project. At the same time, Netlify takes care of the build processes and provides you with necessary build events.
Branch Deploy
Branch deployment was another impressive feature I value in JamStack development. I could remember working on a JamStack project built using Strapi with other teams.
We needed to create a different environment because everyone was working on another task. The branch deploys feature came in handy to create separate branches on our project repository for various tasks. Branch deploys are an inevitable feature that will come in handy while working with the JamStack.
Conclusion
I hope you enjoyed reading through this article. Hopefully, it has introduced you to the benefit of using Jamstack and some of the remarkable features of Jamstack to explore in your next project.