Deploy

Lagon

Deploy your Nuxt Application to Lagon infrastructure.

Lagon is an open-source runtime and platform that allows developers to run TypeScript and JavaScript Serverless Functions close to users.

Nuxt supports deploying on Lagon with minimal configuration (documentation)

Lagon is not yet ready for production workloads
Install the Lagon CLI and login with lagon login before proceeding.
Terminal
npm install --global @lagon/cli esbuild

Testing Locally

  1. Build your Nuxt app
    Terminal
    npx nuxt build --preset lagon
    
  2. Launch a local dev server and open localhost:1234:
    Terminal
    lagon dev ./.output
    

Deploy from your local machine

  1. Build your Nuxt app
    Terminal
    npx nuxt build --preset lagon
    
  2. Run the deploy command. Lagon will ask if you want to link to an existing function or create a new one:
    Terminal
    lagon deploy .output
    

Deploy to preview:

Terminal
lagon deploy .output

Deploy to production:

Terminal
lagon deploy .output --prod

Deploy within CI/CD using GitHub Actions

Add a new environment variable named LAGON_TOKEN, and copy the value from the Tokens section of Lagon's dashboard.

Create a new GitHub Workflow at .github/workflows/lagon.yml:

.github/workflows/lagon.yml
name: Lagon
on:
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: 20
          cache: pnpm
      - run: pnpm install
      - run: pnpm build
        env:
          NITRO_PRESET: lagon
      - uses: lagonapp/github-action@latest
        with:
          lagon_token: ${{ secrets.LAGON_TOKEN }}

If you have committed the .lagon folder

Trigger a deployment locally first, and commit the updated .lagon/config.json file. The GitHub Action will automatically pick the configuration file.

If you haven't committed the .lagon folder

Trigger a deployment locally first, and copy the content of .lagon/config.json. Then, update the workflow configuration:

.github/workflows/lagon.yml
with:
  lagon_token: ${{ secrets.LAGON_TOKEN }}
  config: |
    {
      "function_id": "${{ vars.lagon_function_id }}",
      "organization_id": "${{ vars.lagon_org_id }}",
      "index": ".output/index.mjs",
      "client": null,
      "assets": ".output/public"
    }
Head over Nitro documentation to learn more about the lagon deployment preset.