Usage no npm install needed!

<script type="module">
  import serverlessSf from 'https://cdn.skypack.dev/@serverless/sf';


Serverless Framework V.2


"The future of cloud is outcomes, not infrastructure."



Get Started

Clone repo.

$ git clone https://github.com/serverless/v2.git

Install dependencies.

cd v2 && npm i -g

Pick an example. Each example requires credentials for Amazon Web Services set as environment variables.

Serverless Framework V.2 supports .env files in the same folder as serverless.yml or serverless.js. Create one that looks like this:


Run $ v2.

$ website: v2
  ✔  my-site

     URL  http://serverless-6vql3jp9.s3-website-us-east-1.amazonaws.com

  3s › dev › my-site › Done

You can leverage different environment variables for different stages by using this naming convention:

.env # Default

How To Use A Serverless Component Programmatically

Create a new javascript file, and load/use Components like this:

// To load a Component, instantiate it's class...
const realtimeApp = new RealtimeApp('instanceId', { /* inputs */ })

// To run/deploy/update a Component, call it's default function...
await realtimeApp()

// To run extra functionality, use custom methods that come w/ the Component...
await realtimeApp.loadTest()

How To Use A Serverless Component Declaratively

Use a serverless.yml file, like this:

name: realtimeApp
stage: dev

    accessKeyId: ${secrets:aws_access_key_id}
    secretAccessKey: ${secrets:secret_access_key}

    name: ${name}-${stage}
    code: ./src/backend

Then use your CLI, like this:

# To run/deploy/update all Components, call 'serverless'...
$ serverless

# To run extra functionality that comes with the a component, call this...
$ serverless loadTest myRealtimeApp

# To remove Components in YAML, call this...
$ serverless remove

How To Write A Serverless Component

Use a serverless.js file, like this:

class MyComponent extends Component {

  * Default (Required)
  * - The default functionality to run/provision/update your Component

  async default() { }

  * Remove (Optional)
  * - If your Component removes infrastructure, this is recommended.

  async remove() { }

Created By

  • Eslam Hefnawy - @eahefnawy
  • Philipp Muens - @pmmuens