DEV Community

Sameer Gurung
Sameer Gurung

Posted on • Originally published at Medium on

How to run Serverless offline?

Photo by Aleksandar Cvetanovic on Unsplash

In this blog, I will be demonstrating you how to run Serverless Offline using a serverless plugin that emulates AWS ฮป and API Gateway on your local machine to speed up your development cycles. It helps us save time as we can see logs and also debug in our local machine rather than on cloud vendors.

Local environment reduces conflict with our team members who might be dependant on using the same function (even though in development) that you are working on and might get confused to why the function is not working whilst it was working before. You can make any changes and trials carefree as you will be the only one using this environment (unless you share it to the network) ๐Ÿ˜œ.

This blog is for those who already know basics of Serverless Framework and its workarounds.

The Serverless Framework helps you build serverless apps with radically less overhead and cost. It provides a powerful, unified experience to develop, deploy, test, secure and monitor your serverless applications.โ€Šโ€”โ€ŠServerless Framework

Steps:

Since you already know the basics of Serverless Framework, you must have installed the framework. Next, install the package serverless-offline from npm.

  1. Install packageโ€Šโ€”โ€Šserverless-offline
npm install serverless-offline --save-dev
  1. Add this installed plugin to your serverless project.
plugins:

  - serverless-offline
  1. Run serverless offline using command:
> serverless offline 

or

> sls offline
  1. You can see the list of available endpoints on http://localhost:3000/ and also use http://localhost:3000/ a base endpoint. Additional usage and command line options are available on the pluginโ€™s official documentationpage.

Reference:

  1. https://github.com/dherault/serverless-offline

Top comments (2)

Collapse
 
svetabeta profile image
svetabeta

saved my day

Collapse
 
riyazm16 profile image
Riyazm16 • Edited

abe basics to sabko pata hai, details kaha hai ?? :(