Leveraging Netlify’s serverless functions

Visakh Vijayan
2 min readMar 19, 2024

Quote Quest is our hobby project which we keep working on now and then when we are bored. Today we decided we wanted to shift from Firebase’s serverless functions to Netlify. The reason is simple. We didn’t want to upgrade our basic plan on Firebase just to execute a small function.

Serverless Functions are functions that you can easily deploy on platforms like Firebase and Netlify. They provide you with a NodeJs server i.e. the Platform. All you have to do is add your function to it. And wallah! you have an API endpoint..

What we wanted

Till now, we had two sources from where we got our quotes. One was via Ninja and the other was Gemini. Both of these requests originated from the client in React. We wanted to shift these to Netlify so that we could get a single Netlify endpoint instead. Netlify in turn will call these functions on its servers and give us the output.

Here is what we did

  1. Install Netlify’s npm package using npm install @netlify/functions
  2. Make a folder at /netlify/functions in our project root. Any file you put into this folder becomes an API endpoint that can be accessed at https://<domain>/.netlify/functions/<function>
import type { Context } from '@netlify/functions';
import {…

--

--

Visakh Vijayan
Visakh Vijayan

Written by Visakh Vijayan

Techie from Kerala, India. Days are for coding, nights for weaving tales of tech, travel, and finance. Join me in exploring this multifaceted journey