|
| 1 | +--- |
| 2 | +title: Setup Nuxt Studio |
| 3 | +description: Learn how to install and configure Nuxt Studio to edit your content in production with GitHub authentication. |
| 4 | +navigation: |
| 5 | + title: Setup |
| 6 | +seo: |
| 7 | + title: Nuxt Studio Setup Guide |
| 8 | + description: Learn how to install and configure the self-hosted Nuxt Studio module for your Nuxt Content website. Edit content in production with GitHub authentication. |
| 9 | +--- |
| 10 | + |
| 11 | +::note{to="https://nuxt.studio/docs/setup"} |
| 12 | +This documentation covers only the new open-source Nuxt Studio module. |
| 13 | +Click here to view the documentation for the legacy standalone platform. |
| 14 | +:: |
| 15 | + |
| 16 | +## Install |
| 17 | + |
| 18 | +Add the Nuxt Studio module to your project: |
| 19 | + |
| 20 | +::code-group |
| 21 | +```bash [pnpm] |
| 22 | +pnpm add nuxt-studio@alpha |
| 23 | +``` |
| 24 | + |
| 25 | +```bash [npm] |
| 26 | +npm install nuxt-studio@alpha |
| 27 | +``` |
| 28 | + |
| 29 | +```bash [yarn] |
| 30 | +yarn add nuxt-studio@alpha |
| 31 | +``` |
| 32 | + |
| 33 | +```bash [bun] |
| 34 | +bun add nuxt-studio@alpha |
| 35 | +``` |
| 36 | +:: |
| 37 | + |
| 38 | +Alternatively, use the Nuxt CLI to automatically add the module: |
| 39 | + |
| 40 | +```bash [Terminal] |
| 41 | +npx nuxi module add nuxt-studio@alpha |
| 42 | +``` |
| 43 | + |
| 44 | +## Configure |
| 45 | + |
| 46 | +Add the module to your `nuxt.config.ts` and configure your GitHub repository: |
| 47 | + |
| 48 | +```ts [nuxt.config.ts] |
| 49 | +export default defineNuxtConfig({ |
| 50 | + modules: [ |
| 51 | + '@nuxt/content', |
| 52 | + 'nuxt-studio' |
| 53 | + ], |
| 54 | + |
| 55 | + studio: { |
| 56 | + // Studio admin route (default: '/_studio') |
| 57 | + route: '/_studio', |
| 58 | + |
| 59 | + // GitHub repository configuration (owner and repo are required) |
| 60 | + repository: { |
| 61 | + provider: 'github', // only GitHub is currently supported |
| 62 | + owner: 'your-username', // your GitHub username or organization |
| 63 | + repo: 'your-repo', // your repository name |
| 64 | + branch: 'main', // the branch to commit to (default: main) |
| 65 | + rootDir: '' // optional: if your Nuxt app is in a subdirectory (default: '') |
| 66 | + } |
| 67 | + } |
| 68 | +}) |
| 69 | +``` |
| 70 | + |
| 71 | +::callout |
| 72 | +If your Nuxt Content application is in a monorepo or subdirectory, specify the `rootDir` option to point to the correct location. |
| 73 | +:: |
| 74 | + |
| 75 | +## GitHub OAuth App |
| 76 | + |
| 77 | +Nuxt Studio uses GitHub OAuth for authentication. |
| 78 | + |
| 79 | +::prose-steps |
| 80 | + |
| 81 | +### Navigate to GitHub Developer Settings |
| 82 | + |
| 83 | +Go to [GitHub Developer Settings](https://github.com/settings/developers) and click **New OAuth App** |
| 84 | + |
| 85 | +### Configure the OAuth Application |
| 86 | + |
| 87 | +Fill in the required fields: |
| 88 | +- **Application name**: Your app name |
| 89 | +- **Homepage URL**: `https://yourdomain.com` |
| 90 | +- **Authorization callback URL**: `https://yourdomain.com` |
| 91 | + |
| 92 | +:note[If you want to try studio locally, set the callback url to your local url `http://localhost:3000`] |
| 93 | + |
| 94 | +### Copy Your Credentials |
| 95 | + |
| 96 | +After creating the OAuth app, you'll receive: |
| 97 | + |
| 98 | +- A **Client ID** (visible immediately) |
| 99 | +- A **Client Secret** (click **Generate a new client secret**) |
| 100 | + |
| 101 | +### Set your environment Variables |
| 102 | + |
| 103 | +Add the GitHub OAuth credentials to your deployment platform's environment variables or in your `.env` file in local |
| 104 | + |
| 105 | +```bash [.env] |
| 106 | +STUDIO_GITHUB_CLIENT_ID=<your_github_client_id> |
| 107 | +STUDIO_GITHUB_CLIENT_SECRET=<your_github_client_secret> |
| 108 | +``` |
| 109 | +:: |
| 110 | + |
| 111 | +## Deployment |
| 112 | + |
| 113 | +Nuxt Studio requires a server-side route for authentication. |
| 114 | + |
| 115 | +While static generation remains supported with [Nuxt hybrid rendering](https://nuxt.com/docs/4.x/guide/concepts/rendering#hybrid-rendering), your site must be **deployed on a platform that supports server-side rendering (SSR)** using `nuxt build` command. |
| 116 | + |
| 117 | +If you want to pre-render all your pages, use the following configuration: |
| 118 | + |
| 119 | +```ts [nuxt.config.ts] |
| 120 | +export default defineNuxtConfig({ |
| 121 | + nitro: { |
| 122 | + prerender: { |
| 123 | + // Pre-render the homepage |
| 124 | + routes: ['/'], |
| 125 | + // Then crawl all the links on the page |
| 126 | + crawlLinks: true |
| 127 | + } |
| 128 | + } |
| 129 | +}) |
| 130 | +``` |
| 131 | + |
| 132 | +## Working with Staging/Preview Branches |
| 133 | + |
| 134 | +By default, Studio commits changes to the branch specified in your configuration (typically `main`). However, you can configure Studio to work with a staging or preview branch instead. |
| 135 | + |
| 136 | +This is useful when you want to review changes on a preview environment before merging to production. You can currently handle pull requests manually from GitHub, but automatic PR creation is included in our roadmap and will be implemented in a future release. |
| 137 | + |
| 138 | +::prose-steps |
| 139 | +### Configure |
| 140 | + |
| 141 | +Update your `nuxt.config.ts` to target your staging branch. |
| 142 | + |
| 143 | + :::tip |
| 144 | + You can use environment variables to manage multiple branches for different environments. |
| 145 | + ::: |
| 146 | + |
| 147 | +```ts [nuxt.config.ts] |
| 148 | +export default defineNuxtConfig({ |
| 149 | + studio: { |
| 150 | + repository: { |
| 151 | + owner: 'your-username', |
| 152 | + repo: 'your-repo', |
| 153 | + branch: PROCESS.ENV.STUDIO_GITHUB_BRANCH_NAME, // Target your staging branch instead of main |
| 154 | + } |
| 155 | + } |
| 156 | +}) |
| 157 | +``` |
| 158 | + |
| 159 | +### Deploy |
| 160 | + |
| 161 | +Configure your hosting platform to deploy the staging branch to a preview URL (e.g., `staging.yourdomain.com`). |
| 162 | + |
| 163 | +### Create a Separate GitHub OAuth App |
| 164 | + |
| 165 | +Create a new OAuth App specifically for your staging environment: |
| 166 | + |
| 167 | +- **Application name**: Your App Name (Staging) |
| 168 | +- **Homepage URL**: `https://staging.yourdomain.com` |
| 169 | +- **Authorization callback URL**: `https://staging.yourdomain.com` |
| 170 | + |
| 171 | +### Set Environment Variables |
| 172 | + |
| 173 | +Configure your staging deployment with the staging OAuth credentials and your br |
| 174 | + |
| 175 | +```bash [.env.staging] |
| 176 | +STUDIO_GITHUB_CLIENT_ID=<your_staging_github_client_id> |
| 177 | +STUDIO_GITHUB_CLIENT_SECRET=<your_staging_github_client_secret> |
| 178 | +STUDIO_GITHUB_BRANCH_NAME=<your_staging_branch_name> |
| 179 | +``` |
| 180 | + |
| 181 | +### Access Studio on Staging |
| 182 | + |
| 183 | +Navigate to `https://staging.yourdomain.com/_studio` to edit content. All commits will be pushed to your configured staging branch. |
| 184 | + |
| 185 | +### Merging to Production |
| 186 | + |
| 187 | +Once you're satisfied with changes on your staging branch, create a pull request from your staging branch to your main branch on GitHub to deploy to production. |
| 188 | + |
| 189 | + :::note |
| 190 | + **Pull Request Automation Coming Soon** |
| 191 | + |
| 192 | + :br |
| 193 | + |
| 194 | + Automatic pull request creation from Studio is planned for a future release. For now, you'll need to manually create PRs on GitHub to merge staging changes into your main branch. |
| 195 | + ::: |
| 196 | +:: |
| 197 | + |
| 198 | +### Accessing Studio |
| 199 | + |
| 200 | +After deployment, access the Studio interface by navigating to your configured route (default: `/_studio`): |
| 201 | + |
| 202 | +1. Click **Login with GitHub** if it does not directly redirect to the OAuth app authorization page |
| 203 | +2. Authorize the OAuth application |
| 204 | +3. You'll be redirected back to Studio, ready to edit your content |
| 205 | + |
| 206 | +::note |
| 207 | +Secure OAuth-based login with **Google** should be available quickly in the Beta release. |
| 208 | +:: |
| 209 | + |
| 210 | +::tip |
| 211 | +You can also use the shortcut :kbd{value="meta"} + :kbd{value="."} to redirect to the Studio route. |
| 212 | +:: |
| 213 | + |
| 214 | +## Development mode |
| 215 | + |
| 216 | +Nuxt Studio includes an **experimental** development mode that enables real-time file system synchronization: |
| 217 | + |
| 218 | +```ts [nuxt.config.ts] |
| 219 | +export default defineNuxtConfig({ |
| 220 | + studio: { |
| 221 | + development: { |
| 222 | + sync: true // Enable development mode |
| 223 | + } |
| 224 | + } |
| 225 | +}) |
| 226 | +``` |
| 227 | + |
| 228 | +When enabled, Nuxt Studio will: |
| 229 | + |
| 230 | +- ✅ Write changes directly to your local `content/` directory |
| 231 | +- ✅ Write media changes to your local `public/` directory |
| 232 | +- ❌ Listen for file system changes and update the editor |
| 233 | +- ❌ Commit changes to your repository (use your classical workflow instead) |
0 commit comments