Table of Contents
- Jamstack and Serverless
- Examples of Serverless Functions Used in Jamstack
- Where Can I Host My Serverless App?
- Kuroco, the Enterprise Headless CMS
- Related Articles
'Serverless' is a type of cloud-based systems architecture focused on providing ready-to-use, scalable backend resources on demand. Serverless does not mean that no servers are being used (i.e. behind the scenes), but rather that as a developer - particularly one focused on the front-end - you do not need to worry about creating, writing code for, or maintaining a server on the backend.
Traditionally, businesses would have to set up and maintain additional servers to keep up with increased demand over time, which is costly and time consuming. With enterprise-grade server clusters available from cloud providers like AWS, Google, Microsoft, and many other companies, backend resources are now widely available for any business to tap into online.
While serverless is technically a backend solution, its main use case is automating the backend to allow developers to focus more on the frontend.
‘Serverless’ is also the name of a popular open-source framework built in Node.js, which deploys to AWS. The basis of this framework is that frontend applications can be powered by AWS Lambda functions, the largest “functions as a service” (FaaS) provider. FaaS providers (including AWS and many others on the market) allow frontend software to use functions similar to what would normally be called server-side (for example, when handling API calls to fetch secure data with a token that cannot be stored in the browser).
A serverless framework, combined with FaaS, is potentially a much cheaper solution than running dedicated servers full-time. FaaS usage is only charged per function called, resulting in less overhead during times of low demand.
Jamstack and Serverless
Traditionally, when a front-end application is built, developers will need to connect it to a backend (typically built in Ruby-on-Rails, PHP, Node.js, or other backend languages). With Jamstack, however, front-end developers can instead simply include serverless functions in the source code of their application, and a hosting service provider can handle that functionality (this is considered the ‘serverless’ way).
Once again, the main advantage to this approach is that these serverless functions can automatically scale up or scale down capacity, depending on usage.
A Note on 'Cold Starts' with Serverless Functions
In some cases, if a serverless app is unused for an extended period, the FaaS may not respond to requests as quickly as a dedicated server would, but in most cases this is a minor trade-off, with little (or no) effect on performance. For larger apps with high amounts of traffic, the serverless functions will be constantly active and able to scale instantly on demand.
One issue to be aware of is that on some cloud platforms unused serverless functions may be set to ‘idle’ and require a ‘cold start’ when used again, which can result in slightly slower reaction speeds. This issue does not occur if the application and its functions are being used regularly.
Examples of Serverless Functions Used in Jamstack
- Making API calls to fetch data server-side, before serving the static HTML files to the browser. While Jamstack is often associated with serving static sites from a CDN, it is possible to add dynamic functionality using serverless functions.
- Handling authorization. While it is possible to store JSON web tokens (JWTs) in the browser, it is still necessary to generate the bearer tokens server-side (they cannot be stored in the browser due to obvious security vulnerabilities). Rather than building out your own backend server for this, it can be handled by the host using serverless functions.
A great resource to check out for real examples of serverless functions used in the Jamstack can be found here.
Where can I host my serverless app?
The biggest cloud providers include AWS, Google Cloud, and Azure, providing mainly infrastructure-as-a-service (IaaS) and platform-as-a-service (PaaS) offerings. However, configuration on these platforms can be difficult to set up and will usually still require backend developers to set up and maintain.
Hosting platforms like Netlify, Vercel, as well as headless CMS platforms like Kuroco, can make this process much easier and include a lot of the desired ‘serverless’ functionality most developers need out-of-the-box.
Kuroco, the Enterprise Headless CMS, comes with serverless architecture built right in:
Kuroco is a headless CMS that comes with all the serverless functionality you need for focusing on frontend development. For frontend developers, we provide a powerful API management tool that can connect with virtually any backend systems your enterprise has available - and serve up the data you need to be consumed on the client-side.
For content creators and marketers on your team, our headless CMS allows content to be created and published with ease, to any front end interfaces your app is facing.