Getting Started

Remote Storage

Access your remote storage locally or from other Nuxt projects with our secured proxy.

One of the main features of NuxtHub is the ability to access your remote storage from your local environment or from other Nuxt projects. This is made possible by our secured proxy system.

You need to have deployed your project in order to use this feature.

There are two ways to use the remote storage:

  • Local development: Access your remote storage from your local environment.
  • Other Nuxt projects: Access your remote storage from other Nuxt projects, useful if your frontend is deployed on another hosting platform.

Local Development

Once your project is deployed, you can use the remote storage in your local project.

Start your Nuxt project with:

Terminal
npx nuxt dev --remote

The development project will now use the remote storage from your deployed project and these logs should happen in your terminal:

 Using remote features from https://my-project.nuxt.dev
 Remote storage available: database, kv, blob
That's it! Your local project is now using the remote storage from your deployed project.

To always use the remote storage in your local project, you can add NUXT_HUB_REMOTE=true in your .env file:

.env
NUXT_HUB_REMOTE=true
NuxtHub will use the remote storage from your deployed project as long as you are logged in with the NuxtHub CLI and the local project is linked to a NuxtHub project with nuxthub link or nuxthub deploy.

Self-hosted

If you are not using the NuxtHub Console to manage your project, you can still use the remote storage in your local development environment.

  1. Set the NUXT_HUB_PROJECT_SECRET_KEY environment variable in your Cloudflare Pages project settings and retry the last deployment to apply the changes (you can generate a random secret on https://www.uuidgenerator.net/version4)
  2. Set the same NUXT_HUB_PROJECT_SECRET_KEY and NUXT_HUB_PROJECT_URL environment variables in your local project
    .env
    NUXT_HUB_PROJECT_SECRET_KEY=my-project-secret-used-in-cloudflare-env
    NUXT_HUB_PROJECT_URL=https://my-nuxthub-project.pages.dev
    

Then, start your Nuxt project with:

Terminal
npx nuxt dev --remote
NuxtHub will use the remote data from your deployed project as long as the NUXT_HUB_PROJECT_SECRET_KEY matches the one in your Cloudflare Pages project settings.

Other Nuxt Projects

It is possible to use the remote storage from another Nuxt project. This can be useful if your frontend is deployed on another hosting platform and you want to use your NuxtHub as your backend.

To access your remote storage from another Nuxt project:

  1. Install @nuxthub/core to your project:
pnpm add @nuxthub/core
  1. Add it to the extends section in your nuxt.config and set the remote option to true:
nuxt.config.ts
export default defineNuxtConfig({
  extends: ['@nuxthub/core'],
  hub: {
    remote: true
  }
})
  1. Add the NUXT_HUB_PROJECT_URL and NUXT_HUB_PROJECT_SECRET_KEY environment variables to your project:
.env
NUXT_HUB_PROJECT_URL=https://my-nuxthub-project.pages.dev
NUXT_HUB_PROJECT_SECRET_KEY=my-project-secret-used-in-cloudflare-env

If you haven't, set the NUXT_HUB_PROJECT_SECRET_KEY environment variable in your NuxtHub deployed project and make sure to redeploy.

You can now use the remote storage from your NuxtHub project in your other Nuxt project (both locally and in production).

Copyright NuxtLabs © 2024