DEV Community

Cover image for WTF is Jamstack: The Best Way to Build Content Sites?
Nitin Sharma
Nitin Sharma

Posted on • Originally published at blog.locofy.ai

WTF is Jamstack: The Best Way to Build Content Sites?

In recent years, client-server architecture has taken the web development world by storm by enabling builders to employ a database to store content and a client to request data from the server. With the development of React, Angular, and Vue, concepts such as virtual DOM, JSX, rerendering, two-way binding, and other such topics became jargon for the industry.

These concepts made web apps more powerful with a lot of technologies and tools to integrate alongside databases and servers.

And that’s where the process of creating a web application became more challenging since the developer had to install and configure a number of tools. All of these need numerous hours of development work, delaying the launch of the product.

Having a set of best practices and industry-standard architecture can simplify the process and this has led to the growth of a modern opinionated architecture called Jamstack.

Frameworks like Next.js, Gatsby, and Hugo make good use of this architecture and have brought new ideas to the table as well including incremental site regeneration, TypeScript support, intelligent bundling, and route pre-fetching.

Exploring Jamstack — A Modern Web Architecture

Static websites started to gain popularity in 2015 because of Jekyll and other related technology. In the same year, Mathias Biilmann and Chris Bach from Netlify came up with the term “Jamstack”.

Now, what is Jamstack?

Jamstack is “A modern web development architecture based on client-side JavaScript, reusable APIs, and prebuilt Markup,” according to Mathias Biilmann (CEO & Co-Founder of Netlify).

In short, Jamstack deals with JavaScript, API, and Markup.

You may have built a number of websites with the aid of JavaScript, API, and Markup, so it is not at all new in terms of technologies; instead, it is a fresh approach to how we use them in conjunction.

Jamstack is different from React & Angular in the sense that it is not a framework but an architectural approach that decouples the web experience layer from data and business logic. It allows the easy addition of custom logic and third-party integration through the use of APIs.

Understanding the Technicalities of Jamstack

Jamstack

Let’s take a look under the hood to understand the technologies that power Jamstack:

JavaScript

This is the first element in building a Jamstack website.

If you’re a web developer, you’re probably aware that JavaScript is used to provide dynamic behavior and logic to websites, providing a great user experience. The same idea holds true for Jamstack.

Jamstack decouples all the content, allowing complete freedom, as compared to the traditional architecture where the frontend technology is tied with a database and server.

The J in Jamstack stands for JavaScript, but you may use any JavaScript framework, even Python or Go.

And as a result, Jamstack is more flexible in terms of the front-end technologies you may use.

API

A common technique for connecting clients and servers is an application programming interface (API). We can do it via GRPC, GraphQL, or even REST.

You can think of it as a convenient channel for passing the client’s request and the server’s response.

Let’s take an example.

Client-Server Communication

When the user asks about the book’s data, the server responds with JSON data, as shown in the above figure.

Server-side actions are abstracted into reusable APIs and made accessible using JavaScript over HTTPS, much as how APIs function in Jamstack. For that, you may use either your own custom function or services from third parties.

That is why the server no longer has to perform the heavy lifting; everything is now handled on the client side. And, as APIs become more widely available, they may be utilized as microservices to easily integrate and link to provide a variety of features.

Markup

The third element of Jamstack is markup.

A content request is normally sent to the server by a user. The server follows a long sequence to find the appropriate information and then responds. A user should not have to wait that long.

This is where markup comes into play.

Jamstack employs prebuilt markup instead of relying on the server to build content for each request. Let’s dig a little deeper.

Static site generators take data or information as input, assess it, and then generate prebuilt HTML. These prebuilt markups, or HTML pages, are hosted on CDN, making it easy for visitors to get the desired content.

There are over 300 static site generators available to choose from.

How does Jamstack Differ from Traditional Architecture?

Before HTML, CSS, and JavaScript were introduced, websites were exclusively static; however, after their debut, developers began to create dynamic webpages that were then served by servers.

In essence, when a user wants information, the client asks the server for the content, the server retrieves the specified content, applies some logic, and then delivers the content.

But as web development became more complex, some comment patterns and architectures emerged.

And it was from there the term Jamstack was born.

Here, the developer uses JavaScript or another javascript framework to write the code, which is then pushed to a source repository like Git. From there, the files are automatically sent to the content delivery network (CDN), giving us access to Jamstack’s pre-rendering functionalities.

A CDN may be thought of as a group of servers positioned across the world to load websites quickly and efficiently.

Benefits of Jamstack

1. Static Site

To begin with, Jamstack is not only for creating static websites; you can also develop dynamic websites, but they will be shown as static pages. This distinguishes Jamstack from other web development frameworks.

Because static websites are built at build time, they are faster and SEO friendly.

2. Faster performance

A static site generator receives a set of content or templates as inputs and then provides the result, which is essentially prebuilt markup that is distributed to a CDN.

As a result, when a user requests information, the output in the form of pages from a CDN may be instantly delivered, making the process easier and faster.

CDN distributes website content to many groups of servers so that when someone requests the content, it is sent from the closest server, allowing for faster communication.

3. Cost-effective, and economical

Jamstack websites and web apps are not hosted on an original server; instead, they are provided straight via a CDN, which reduces costs significantly.

The process of upgrading the website or web apps is generally automated, which simplifies the work process significantly.

Even CDNs like Cloudflare offer a generous free trial and there is support for CI/CD pipeline with Github. This makes Jamstack cost-effective and inexpensive.

4. More Secure

Traditional server-side apps are vulnerable to a variety of attacks since they employ many APIs to transfer content to the original server.

Because CDN contains just read-only files and no active connections, the likelihood of being exploited by a hacker is much lower.

5. Scalable

We have no physical server in Jamstack, and even updating the websites is primarily automated, which is why we have to just update the website based on the tech stack we use.

There is no complicated logic that can be cached since the web pages are saved in the CDN eliminating the need to have a running server & with automatic deployment, it is simple to scale these websites.

Should You Consider Jamstack for Your Next Project?

With all the benefits that come with Jamstack, it can be an ideal choice for your content-heavy projects. Since Jamstack can be developed with a number of technologies, including frameworks and APIs, the learning curve is shallow.

In fact, if you are familiar with React and GraphQL, you can get started with Jamstack. Even if you are familiar with some other technologies, you may follow the same steps to incorporate them.

Lastly, Jamstack makes your website operate well, load quickly, make it secure, and be scalable.

The two prominent frameworks that make use of Jamstack are Gatsby and Next.js. You can generate pixel-perfect and highly extendible code in both of these frameworks directly from Figma and Adobe XD designs using the Locofy.ai plugin.

Using the plugin, you can break down your design into components that expect props which makes it easy to plug in a CMS of your choice and build a Jamstack app.

Hope you like it.

That’s it — thanks.

Top comments (2)

Collapse
 
fruntend profile image
fruntend

Сongratulations 🥳! Your article hit the top posts for the week - dev.to/fruntend/top-10-posts-for-f...
Keep it up 👍

Collapse
 
alizulfaqar profile image
Ali Zulfaqar

Nice article