The Deploy to Layer0 button lets users deploy a project to the Layer0 platform with just a few clicks, no command-line needed! It's a quick and easy way for users to get a working instance of your framework or project template.

This guide walks you through some deploy button examples and how you can setup a GitHub repository for your users to deploy to Layer0 with a simple click.

The Deploy to Layer0 button lets users easily clone and deploy an example project to Layer0. Under the hood the platform will clone the example to the user's GitHub account and leverage GitHub Actions to deploy to it to their personal Layer0 account.

To deploy using this method, users need to have an existing GitHub account.

Below are a list of example site you can deploy right now using our deploy buttons:

To configure your own project to be deploy button ready, there's a few steps to take.

  1. First, your project needs to already be configured and initialized with Layer0. See our Getting Started guide for initial setup.
  2. Next, create a basic deploy script as described below. Typically, this can simply be layer0 deploy, but if your site requires additional processing outside of the standard Layer0 build/deploy process, you will need to modify this script to include the necessary steps to make your site production-ready.
  3. Create a GitHub workflow as described below. This makes sure GitHub Actions is properly configured to build the project.

// additional scripts may need to be called based on your app build process
"deploy": "layer0 deploy",

Lastly, create a GitHub workflow file called layer0.yml. This will be triggered automatically by Layer0 during the deploy process.

name: Deploy to Layer0

on:
  workflow_dispatch:

jobs:
  deploy-to-layer0:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v1
      - uses: actions/setup-node@v1
        with:
          node-version: 14
          registry-url: https://npm-proxy.fury.io/moovweb/
      - run: npm ci
      - run: npm run deploy -- --token=$LAYER0_DEPLOY_TOKEN
        env:
          LAYER0_DEPLOY_TOKEN: ${{secrets.LAYER0_DEPLOY_TOKEN}}

secrets.LAYER0_DEPLOY_TOKEN is automatically injected into your cloned repository during the deploy process. Do not change the name of this variable or the deploy process will fail.

Once everything is setup, you can test your deploy button by appending your GitHub repository full URL to https://app.layer0.co/deploy?repo=.

For example, using our Next.js example located at https://github.com/layer0-docs/layer0-nextjs-example would become https://app.layer0.co/deploy?repo=https%3A%2F%2Fgithub.com%2Flayer0-docs%2Flayer0-nextjs-example

Now, you can embed this link to let users instantly clone and deploy the project to Layer0!