Member-only story
Build a Serverless App With Netlify and JavaScript
A beginner’s introduction to Netlify serverless functions
In this article, you will learn the following:
- What is serverless and when to use it
- Which providers support it
- How to set up a project with Netlify
- Ways to build an example app with Netlify’s serverless functions
- Deployment
What Is Serverless and When to Use It?
Looking at the word “serverless,” you might think that your code doesn’t need a server to run. But in reality, that’s not the case. After all, how else will your program execute?
Slobodan Stojanović explains serverless in his book by comparing it with a washing machine. In general, people only use their washing machines for five to fifteen hours every week. Yet, it sits in the kitchen sipping power even when no one is using it. For this reason, some end up using laundromats. Here, you would only pay for the time taken to wash your clothes.
Likewise, there is a chance that your server is running idle, waiting for requests. Even if it seldom receives any traffic, it is still costing you a hefty fee. In this case, wouldn’t it be great to only pay for the time that your server used to process requests?
This is where serverless comes in. It is a method of running projects on the cloud on a pay-per-use basis. The best part? You only need to focus on writing your code. There is no need to worry about the hosting environment or the underlying OS. Your cloud provider will handle everything for you. This reduces stress by a large extent.
Which Providers Support It?
Almost all cloud hosting providers let you build serverless apps. AWS Lambda, Google Cloud Functions, and Netlify are notable examples.
In this article, we will create a serverless function using Netlify. It will take in a website link as an argument and use Mozilla’s Readability API to give you the content of that site. Since it will be on a web server, we can invoke it using an API endpoint.