Getting Started

Deploy

How to deploy your full-stack Nuxt project to your Cloudflare account.
To deploy your Nuxt application on the Edge, we use Cloudflare Pages. Therefore, we require you to create a Cloudflare account.
You can deploy NuxtHub projects with a free Cloudflare account.

NuxtHub Admin

The NuxtHub Admin is made to simplify your experience with NuxtHub, enabling you to effortlessly manage teams and projects, as well as deploying NuxtHub application with zero-configuration on your Cloudflare account.

Quickstart

  1. Login to https://admin.hub.nuxt.com
  2. Connect your Cloudflare account by clicking on Create a new token with required permissions and follow the instructions
  3. You are now ready to deploy your Nuxt project to your Cloudflare account!

Cloudflare Pages CI

It is possible to use Cloudflare Pages CI to deploy your project by connecting your GitHub or GitLab account. Once your repository is connected, each commit will trigger a new deployment.

  1. Open the NuxtHub Admin
  2. Click on New Project then Import a GitHub repository
  3. Select your Github repository
  4. Click on Import repository
That's it! NuxtHub will automatically configure the necessary resources and environment variables for you start a deployment on Cloudflare.

NuxtHub CLI

If you do your first deployment with the NuxtHub CLI, you won't be able to attach your GitHub/GitLab repository later on due to a Cloudflare limitation.

You can deploy your local project with a single command:

Terminal
npx nuxthub deploy

The command will:

  1. Ensure you are logged in on admin.hub.nuxt.com
  2. Link your local project with a NuxtHub project or help you create a new one
  3. Build your Nuxt project with the correct preset
  4. Deploy it to your Cloudflare account with all the necessary resources
  5. Provide you with a URL to access your project
You can also install the NuxtHub CLI globally with: npm i -g nuxthub.

GitHub Action

To deploy your project with a GitHub Action, you can use the following workflow:

.github/workflows/deploy.yml
name: Deploy to Cloudflare with NuxtHub Cli
on:
  push:
    branches: ['main']
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - uses: pnpm/action-setup@v4
        name: Install pnpm
        with:
          version: 9
          run_install: false
      - name: Install Node.js
        uses: actions/setup-node@v4
        with:
          node-version: 20
          cache: 'pnpm'
      - name: Get pnpm store directory
        shell: bash
        run: |
          echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
      - uses: actions/cache@v4
        name: Setup pnpm cache
        with:
          path: ${{ env.STORE_PATH }}
          key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
          restore-keys: |
            ${{ runner.os }}-pnpm-store-
      - name: Install dependencies
        run: pnpm install
      - name:  Deploy with nuxt-hub cli
        run: npx nuxthub deploy
        env:
          NUXT_HUB_PROJECT_KEY: ${{ secrets.NUXT_HUB_PROJECT_KEY}}
          NUXT_HUB_USER_TOKEN: ${{ secrets.NUXT_HUB_USER_TOKEN }}

You need to add the following secrets to your GitHub repository:

  • NUXT_HUB_PROJECT_KEY: Your project key (available in your project settings in the NuxtHub Admin or in your .env file if you ran nuxthub link)
  • NUXT_HUB_USER_TOKEN: Your user token available in your profile settings → Tokens in the NuxtHub Admin
We recommend to create a new user token for the Github CI so you can revoke it at any time or add an expiration date.
This GitHub action uses pnpm to install dependencies. If you are using npm or yarn, we recommend you to adapt the action to your needs.

Self-hosted

You can deploy your project on your own Cloudflare account without using the NuxtHub Admin.

For that, you need to create the necessary resources in your Cloudflare account and configure your project to use them:

You only need to create these resources if you have explicitly enabled them in the Hub Config.

Then, create a Cloudflare Pages project and link your GitHub or Gitlab repository and choose the Nuxt Framework preset in the build settings.

Once your project is created, open the Settings -> Functions tab and set:

  • Placement: Smart
  • KV namespace bindings
    • Set the variable name as KV and select your KV namespace created
    • Set the variable name as CACHE and select your KV namespace for caching created
  • R2 bucket bindings
    • Set the variable name as BLOB and select your R2 bucket created
  • D1 database bindings
    • Set the variable name as DB and select your D1 database created

Go back to the Deployment tab and retry the last deployment by clicking on ... then Retry deployment.

Once the deployment is done, you should be able to use npx nuxt dev --remote after configuring the remote storage