Web Development
Build Studio Web: a three-page website with a shared header, a persistent light/dark theme, server-rendered content, and a path to production. Follow the files in order to assemble a complete small application. Examples target Nuxt 4's app/ directory structure and npm.
How to follow this tutorial
Technical guides often shorten names into acronyms. Use this glossary whenever a short form is unfamiliar; the definitions explain what each term means in this application.
Acronyms and abbreviations
| Short form | Full name | Meaning in this tutorial |
|---|---|---|
| SEO | Search Engine Optimization | Helping search engines discover and understand pages through useful content, descriptive metadata, and accessible structure. |
| SSR | Server-Side Rendering | Generating a page's HTML on the server before sending it to the browser. |
| API | Application Programming Interface | A defined way for software to interact. Here, the status endpoint lets a page request data from the server. |
| CI | Continuous Integration | Automatically checking proposed code changes, including type checks, builds, and tests. |
| CD | Continuous Delivery or Continuous Deployment | Delivery prepares a verified release for promotion; deployment also promotes it automatically. This tutorial publishes an image and deploys it in a separate step. |
| HTML | HyperText Markup Language | Describes a page's structure and meaning, including headings, links, and buttons. |
| CSS | Cascading Style Sheets | Controls presentation, including colors, spacing, and responsive layout. |
| JS / TS | JavaScript / TypeScript | JavaScript supplies application behavior; TypeScript adds source-code type checks. File extensions .js and .ts identify their source files. |
| UI | User Interface | The visible controls and content people interact with, such as the header and theme button. |
| URL | Uniform Resource Locator | An address such as https://studio.example.com/about, identifying where a resource can be requested. |
| HTTP | Hypertext Transfer Protocol | The request-and-response rules used by browsers and web servers. |
| HTTPS | Hypertext Transfer Protocol Secure | HTTP protected by TLS, encrypting traffic and allowing the browser to authenticate the server through its certificate. |
| TLS | Transport Layer Security | The protocol securing the public HTTPS connection handled by the reverse proxy. |
| JSON | JavaScript Object Notation | A text format for exchanging structured data and writing files such as package.json. |
| YAML | YAML Ain't Markup Language | A configuration format used by Compose and GitHub Actions. Indentation expresses nesting. |
| DOM | Document Object Model | The browser's in-memory representation of the document, which Vue updates when reactive state changes. |
| DNS | Domain Name System | Resolves a hostname to records such as the deployment server's network address. |
| IP / IPv4 / IPv6 | Internet Protocol / version 4 / version 6 | Network addressing used to reach the host. DNS A records contain IPv4 addresses; AAAA records contain IPv6 addresses. |
| SSH | Secure Shell | An encrypted way to connect to a remote host and run terminal commands; it can also authenticate Git connections. |
| SSO | Single Sign-On | Organization-managed authentication that may require authorizing a token before it can access a private package. |
| PAT | Personal Access Token | A credential with selected permissions, used here to pull a private image from the registry. |
| GHCR | GitHub Container Registry | The service at ghcr.io that stores the Docker images published by the workflow. |
| SHA | Secure Hash Algorithm | The name behind Git's commit-hash terminology. Here, the commit SHA identifies the source revision used as an image tag; it is not the image's own digest. |
| LTS | Long-Term Support | A release line maintained for an extended period, such as the Node.js line selected for this example. |
| CLI | Command-Line Interface | A tool operated through terminal commands, such as npm or Docker. |
| WSL | Windows Subsystem for Linux | A way to run a Linux environment and its shell tools on Windows. |
| ARIA | Accessible Rich Internet Applications | Accessibility semantics supplied by attributes such as aria-pressed, which communicates a button's toggle state. |
Nuxt, Vue, Vite, Nitro, and Pinia are tool names; you do not need to expand them. npm is the name of the package-management tool used here. A file's extension identifies its format; it does not tell you where to execute it.
Start with Stage 1 and work through Stage 6 to build the local website. Stage 7 explains what happens behind the scenes, Stage 8 is an optional API exercise, and Stage 9 verifies the result. Stages 10 and 11 package and publish it. You do not need Docker, a domain, or a GitHub account to complete the local website.
Use a code editor to create and save files, a terminal to execute commands, and a browser to view the website. Unless a step says otherwise, commands run in the studio-web project directory on your own computer. File paths are relative to that directory. Copy the contents of a file example into the named file; do not paste Vue, JSON, CSS, or YAML into the terminal.
Examples labelled Bash use a Unix-style shell, available on Linux, macOS, or Windows through WSL or Git Bash. npm and Docker commands also work in PowerShell, but later export commands and shell scripts use Bash syntax. In Windows PowerShell, use curl.exe for the HTTP checks to avoid the older curl alias. On Windows, an npm script-policy error can often be avoided by invoking npm.cmd.
Reading convention: commands show what you type without a shell prompt. Lines beginning with # in shell and environment examples are comments. Replace uppercase placeholders such as YOUR_USERNAME with your own values; example.com addresses are demonstrations. Do not substitute your real values into the handbook application itself.
The web stack
Browser, server, and source code
The browser is the client: it displays the interface and responds to clicks. A server is a running program that answers requests. A Uniform Resource Locator (URL) identifies a resource; the hostname locates the site and the path selects a page, such as /about. Hypertext Transfer Protocol (HTTP) is the request-and-response protocol between them; its secure form, HTTPS, adds encryption in transit. Localhost refers to the computer making the request, and a port such as 3000 selects a listening program on that computer.
HyperText Markup Language (HTML) describes document structure, Cascading Style Sheets (CSS) control appearance, and JavaScript supplies behavior. TypeScript adds checks to JavaScript source and is compiled away before execution. A dependency is another package your project uses. Node.js executes JavaScript outside the browser, while npm installs packages and runs commands declared in package.json.
A browser requests a URL over HTTP. The server returns HTML, styles, and JavaScript. Vue describes interactive UI; Nuxt assembles routing, rendering, and server endpoints around Vue. Vite supplies Nuxt's default development server and application build tooling. Nitro builds and runs the production server.
| Tool | Responsibility in this app |
|---|---|
| Nuxt | Pages, layouts, auto-imports, SSR, and head metadata. |
| Nitro | Builds and runs Nuxt’s production server, including server endpoints and deployment output. |
| Vite | Fast development feedback and compilation. Configure it through Nuxt's vite option when necessary. |
| TypeScript | Checks contracts such as the two permitted theme values before deployment. |
| Pinia | Owns shared reactive theme state and the toggle action. |
| Docker / CI/CD | Package the server, verify changes, publish releases, and deploy a selected version. |
A standalone Vite Vue app is a good fit for a browser-only tool. It needs additional routing and rendering decisions. For this public website, Nuxt supplies those conventions together. Do not create a separate Vite application inside the Nuxt project.
Stage 1: Create the project
Prepare your computer
- Install Node.js 24 Long-Term Support (LTS) from the official Node.js downloads. npm is included in the usual installer. Reopen your terminal after installation so it sees the new commands.
- Install a code editor, such as Visual Studio Code, and open a terminal: Terminal on macOS/Linux, or your chosen shell on Windows.
- Create a folder for your projects using your file manager and open a terminal in that folder. The scaffold command below creates studio-web inside it; do not run it in an existing application directory.
node --version
npm --versionExpected result: both commands print version numbers; Node should report v24.x. “Command not found” means the installation is missing or the terminal cannot find it. Fix that before continuing.
The stack has three main phases. During development, Nuxt coordinates Vite so edits quickly appear in the browser. During a production build, Vite compiles application assets and Nitro prepares the server output. After deployment, Nitro handles incoming HTTP requests and serves the application.
Vue supplies components and reactivity. Nuxt connects those components to routes, layouts, data loading, and server rendering. TypeScript checks source-code contracts; Pinia manages shared application state. Docker packages the built application, while CI/CD verifies changes and moves release artifacts toward production.
Run the following commands one line at a time, selecting npm when prompted. The v4 template selects the Nuxt 4 starter used by this tutorial. npm may ask permission to download its scaffolding package. Wait for each install to finish before continuing. Keep package-lock.json in Git so CI and Docker use the same resolved packages.
npm create nuxt@latest studio-web -- -t v4
cd studio-web
npm install
npm install pinia @pinia/nuxt
npm install -D typescript vue-tsc
npm run devThe first command creates the project; cd enters it. The install commands add the application's dependencies and the tools used for type checking. npm run dev starts the development server and stays running while you work. Stop it with Ctrl+C.
Checkpoint: open the local URL printed by Nuxt and confirm that the starter page appears. If port 3000 is occupied, use the alternative URL Nuxt prints. Then stop the server with Ctrl+C before editing the configuration and assembling the example.
Open studio-web in your editor. Replace nuxt.config.ts with the next example and create an empty app/assets/css/main.css file now, so the configured CSS path exists. In the editor, create the parent folders if missing. The ~ alias resolves to app/ in this structure. Leave the server stopped until the complete set of files is ready in Stage 6.
// nuxt.config.ts
export default defineNuxtConfig({
modules: ['@pinia/nuxt'],
ssr: true,
css: ['~/assets/css/main.css'],
nitro: { preset: 'node-server' },
runtimeConfig: {
public: { siteUrl: 'http://localhost:3000' },
},
})modules installs Pinia's Nuxt integration. ssr explicitly enables server rendering, which is already Nuxt's default. css loads the shared stylesheet on every page. The Nitro preset selects a Node.js server deployment. Public runtime configuration supplies a site origin that the SEO composable can also read in the browser.
Merge these scripts into the scaffold's package.json, preserving its dependencies and other fields. Nuxt generates TypeScript configuration in .nuxt/; keep the scaffold's root tsconfig.json. Development transpilation does not replace an explicit type check.
"scripts": {
"dev": "nuxt dev",
"build": "nuxt build",
"preview": "nuxt preview",
"postinstall": "nuxt prepare",
"typecheck": "nuxt typecheck"
}This is a JSON fragment to merge into package.json, not a complete replacement file. dev runs the development server, build produces deployable output, and preview checks a production build locally. postinstall generates Nuxt's supporting files after installation. typecheck checks TypeScript and Vue templates without deploying anything.
Find the existing scripts object in package.json and replace that object with this one, preserving the other properties. JSON requires double-quoted keys, commas between properties, and no trailing comma after the last property. Save the file; malformed JSON will prevent npm from running any script.
Stage 2: Files & responsibilities
Action: use the tree below as an assembly checklist. In Stages 3–6, create each named application file and paste its complete example. Replacing app/app.vue removes the starter welcome screen. Docker and workflow files are only needed in Stages 10–11; the optional images folder can remain empty or be omitted.
studio-web/
app/
app.vue
assets/
css/
main.css
images/
components/
AppHeader.vue
ThemeToggler.vue
composables/
usePageSeo.ts
layouts/
default.vue
pages/
index.vue
about.vue
contact.vue
stores/
theme.ts
public/
robots.txt
nuxt.config.ts
package.json
package-lock.json
Dockerfile
.dockerignore
compose.yaml
.github/
workflows/
ci.ymlThis tree is a map of files to create, not a terminal command. Files under app/ form the Vue application. The root configuration controls Nuxt, public/ contains files served at unchanged URLs, and the Docker and workflow files describe packaging and automation.
The root app binds the HTML theme. The default layout owns the shared shell. Pages own route content, components own reusable UI, and the store owns theme transitions. Keep secret-bearing endpoints in the root server/ directory if you add a backend later.
How the visible page is assembled
Think of the interface as nested containers. app/app.vue is the application entry component. It places NuxtPage inside NuxtLayout. The default layout provides the header and footer, and its slot receives the selected page. Visiting /about therefore displays the About content inside the same shell used by Home and Contact.
Inside the header, AppHeader.vue composes the navigation links and ThemeToggler.vue. The toggler calls the theme store's action; the app reads that same store to set the HTML theme attribute. Neither the header nor each individual page needs its own copy of the theme preference.
Application files: what belongs where?
| File or directory | Responsibility | Example change |
|---|---|---|
app/app.vue | Connect the top-level layout and current page, and apply application-wide head behavior. | Bind the shared theme to the HTML element. |
app/layouts/default.vue | Define the reusable page shell and the place where route content appears. | Add a footer or change the main content container for all three pages. |
app/pages/ | Provide route-specific content and invoke page-specific SEO. | Edit the About text without changing the shared header. |
app/components/ | Define UI pieces that pages or layouts can compose. | Change the theme button's label or add another navigation link in AppHeader. |
app/stores/theme.ts | Own shared reactive theme state, validate its initial cookie value, and expose the toggle action. | Change how a preference is saved, while keeping callers consistent. |
app/composables/usePageSeo.ts | Reuse setup behavior that registers metadata for the calling page. | Apply a consistent site-name suffix to page titles. |
app/assets/css/main.css | Define global styles, theme variables, and responsive layout rules. | Change the dark palette or the header's narrow-screen arrangement. |
A component has a template and renders UI. A composable packages reusable setup logic; calling it does not create a visible element. A store coordinates state that multiple consumers share. Keep a temporary value used by only one component, such as whether its help text is expanded, in that component unless another part of the application needs to coordinate it.
How filenames become URLs
Nuxt discovers files in app/pages/ and builds the router from them. Here, index.vue becomes /, about.vue becomes /about, and contact.vue becomes /contact. Creating a component in app/components/ does not create a route: it must be rendered by another component, layout, or page.
If you later add app/pages/projects/index.vue, its URL is /projects. A file named app/pages/projects/[id].vue defines a dynamic route such as /projects/42, whose id can be read from the route parameters. These are extensions to the example, not files needed for the three-page app.
Public assets, configuration, and server code
public/robots.txt is served at /robots.txt. Public files retain their names and are accessible to visitors, so never place secrets there. Assets under app/assets/ participate in the application build when imported or configured, as the shared stylesheet is in nuxt.config.ts.
nuxt.config.ts configures framework behavior: modules, rendering, global CSS, the deployment preset, and runtime configuration defaults. package.json declares dependencies and commands; package-lock.json records the resolved dependency graph for repeatable installs. The root tsconfig.json connects the project's TypeScript configuration to Nuxt's generated configuration.
The optional root server/ directory contains code executed on the server. For example, server/api/status.get.ts defines a GET endpoint at /api/status. A page can call that endpoint through useFetch. Keep private credentials in server runtime configuration and validate what the endpoint returns; server execution does not make the response private.
Packaging and automation files
Dockerfile describes how to build an image and start its production process. .dockerignore controls which local files enter the build context. compose.yaml describes how to run that image, including ports and environment variables. These files serve different purposes: changing a page requires rebuilding the image, while changing a runtime environment variable requires recreating the container with the new configuration.
.github/workflows/ci.yml defines the automated checks and image publishing steps run by GitHub Actions. It consumes the same package scripts and Dockerfile used locally. Deployment selects a published image and provides production configuration; it should not require editing application source on the host.
Source files versus generated files
Maintain the application source, configuration, lockfile, and deployment definitions in version control. Nuxt generates .nuxt/ for development support and .output/ for the production build; npm installs dependencies into node_modules/. Exclude these generated directories from Git and do not fix application behavior by editing them, because the next install or build can replace them.
Where should a change go? For a new route, add a page. For repeated visual UI, add or update a component. For a shared page shell, change the layout. For shared state transitions, change the store. For reusable setup behavior, use a composable. Extend the existing file that owns the behavior before introducing another abstraction.
Stage 3: App shell & header
Read a Vue single-file component
A .vue file is a single-file component: one file can contain its JavaScript or TypeScript logic, an HTML-like template, and optional styles. <script setup lang="ts"> declares TypeScript setup logic whose variables and functions the template can use. <template> describes the UI. You do not write a separate HTML page for each component.
import brings an exported value from another module into this file. const declares a binding, and calling a function uses parentheses. Nuxt auto-imports framework helpers such as useHead, your composables, and components in its conventional directories. An ordinary Vue project would need more explicit imports. Our store imports stay explicit to make ownership clear.
Action: create or replace the three files below. They refer to the store, toggler, and pages that you will create next. Keep the server stopped during assembly; an unresolved reference at this point means the remaining files are not ready yet.
app/app.vue
<script setup lang="ts">
import { useThemeStore } from '~/stores/theme'
const theme = useThemeStore()
useHead(() => ({
htmlAttrs: { lang: 'en', 'data-theme': theme.mode },
}))
</script>
<template>
<NuxtLayout><NuxtPage /></NuxtLayout>
</template>The setup block obtains this application's theme store. Passing a function to useHead makes the HTML attributes follow reactive state changes. In the template, NuxtLayout selects the layout and NuxtPage renders the current route inside it.
app/layouts/default.vue
<template>
<div class="shell">
<a class="skip-link" href="#main">Skip to content</a>
<AppHeader />
<main id="main" tabindex="-1"><slot /></main>
<footer>Studio Web · Built with Nuxt</footer>
</div>
</template>The default layout surrounds every page with the same header, main region, and footer. slot marks where page content appears. The skip link targets the main region, whose negative tabindex allows focus without adding another stop to normal Tab navigation.
app/components/AppHeader.vue
<template>
<header class="headerbar">
<NuxtLink class="brand" to="/">Studio Web</NuxtLink>
<nav aria-label="Main navigation">
<NuxtLink to="/">Home</NuxtLink>
<NuxtLink to="/about">About</NuxtLink>
<NuxtLink to="/contact">Contact</NuxtLink>
</nav>
<ThemeToggler />
</header>
</template>The header combines the brand, three route links, and the reusable theme button. Each to value matches a page URL. Keeping the header in one component means navigation changes apply to every page through the layout.
Nuxt auto-imports these components. NuxtLink produces real links and supports client navigation; use ordinary anchors for external destinations. File-based pages provide the route definitions. The navigation landmark and skip link help keyboard and screen-reader users.
Stage 4: Pinia & ThemeToggler
Goal: one button changes the site's palette and remembers the choice after reload. State is a value that can change while the app runs. Reactive state tells Vue to update the UI when that value changes. A cookie is a small value stored by the browser and sent with matching requests, allowing the server to read this preference too.
Action: save the following two files. In the store, type Theme = 'light' | 'dark' restricts the permitted TypeScript values. ref<Theme> creates a reactive container; use its .value in script code. Pinia unwraps returned refs on the store, so components read theme.mode without .value.
app/stores/theme.ts
// app/stores/theme.ts
import { defineStore } from 'pinia'
import { ref } from 'vue'
type Theme = 'light' | 'dark'
export const useThemeStore = defineStore('theme', () => {
const cookie = useCookie<string>('studio-theme', {
default: () => 'light',
path: '/',
sameSite: 'lax',
maxAge: 60 * 60 * 24 * 365,
})
const mode = ref<Theme>(cookie.value === 'dark' ? 'dark' : 'light')
function toggle() {
mode.value = mode.value === 'light' ? 'dark' : 'light'
cookie.value = mode.value
}
return { mode, toggle }
})defineStore gives the store a stable identifier. Its setup function reads the preference cookie and creates a reactive mode. The toggle action changes that mode and writes the same value back to the cookie. Returning the state and action makes them available to components. The cookie applies across the site and lasts up to one year.
The expression condition ? valueA : valueB chooses valueA when the condition is true and valueB otherwise. Here it validates the initial preference and switches between themes. sameSite: 'lax' limits when a browser sends the cookie on cross-site requests; maxAge is measured in seconds. This cookie contains a display preference, not an authentication credential.
The union type catches invalid assignments during development; the cookie check validates persisted input at runtime. useCookie can read the request cookie during SSR. A first visit defaults to light. This intentionally uses an explicit preference rather than guessing the operating-system theme.
app/components/ThemeToggler.vue
<script setup lang="ts">
import { useThemeStore } from '~/stores/theme'
const theme = useThemeStore()
</script>
<template>
<button
type="button"
:aria-pressed="theme.mode === 'dark'"
aria-label="Dark theme"
@click="theme.toggle()"
>
{{ theme.mode === 'dark' ? 'Dark' : 'Light' }}
</button>
</template>The colon in :aria-pressed binds an attribute to an expression; the at-sign in @click attaches an event handler. The text interpolation displays the current mode. The component owns the button's presentation, while the store owns the rule for changing themes.
The component delegates changes to the store. Its stable accessible name is “Dark theme”; aria-pressed announces whether that mode is enabled. A native button supports Enter and Space. Store properties remain reactive through theme.mode; use storeToRefs(theme) if destructuring state.
Double braces in a Vue template display an expression's value as text. The button's label follows the store, while the root app's data-theme attribute follows the same value. Later, CSS selects the matching palette. Changing the state does not edit the stylesheet or reload the page.
The cookie persists the preference across reloads; Pinia shares it across components and page navigation. The app's reactive useHead updates data-theme on the HTML element. This small app does not synchronize already-open tabs. Do not publicly cache cookie-dependent HTML without isolating theme variants.
Stage 5: Three pages & SEO
Goal: give each URL its own content, browser-tab title, and search description. SEO means search engine optimization: helping search engines understand and discover useful pages. Metadata belongs in the document's head and usually is not visible in the page body. A canonical URL declares the preferred public address for a page; Open Graph fields describe it to services that create link previews.
Action: create the SEO composable, configure the local origin, then create all three page files below. Each page calls the same function with different text. The parameter annotations title: string and description: string require text arguments; export makes the function available outside its module.
app/composables/usePageSeo.ts
// app/composables/usePageSeo.ts
export function usePageSeo(title: string, description: string) {
const route = useRoute()
const config = useRuntimeConfig()
const canonical = new URL(route.path, config.public.siteUrl).href
useSeoMeta({
title: title + ' | Studio Web',
description,
ogTitle: title + ' | Studio Web',
ogDescription: description,
ogType: 'website',
ogUrl: canonical,
twitterCard: 'summary',
})
useHead({ link: [{ rel: 'canonical', href: canonical }] })
}A composable is a reusable function that combines Vue or Nuxt behavior. This one receives page-specific text, reads the route and configured origin, and constructs an absolute canonical URL. useSeoMeta registers search and social metadata; useHead adds the canonical link. Keeping these rules together prevents pages from assembling metadata differently.
Call the composable synchronously in each page setup. Each page supplies a distinct title and description. The canonical URL omits tracking query parameters and hashes. Set NUXT_PUBLIC_SITE_URL to the public HTTPS origin at deployment; localhost is only the development fallback.
Configure the public site URL
NUXT_PUBLIC_SITE_URL is an environment variable, not a file or a page route. Nuxt maps this name to runtimeConfig.public.siteUrl, overriding the default declared in nuxt.config.ts. The SEO composable reads it through useRuntimeConfig(). Because it is public configuration, its value is available in the browser and must not contain secrets.
For local development, create a file named .env in the Nuxt project root, beside nuxt.config.ts and package.json:
# .env in studio-web/, beside nuxt.config.ts
NUXT_PUBLIC_SITE_URL=http://localhost:3000Nuxt loads this file during development. Restart the development server after changing the value. Match the port printed by your server if it differs from 3000. Keep local environment files out of version control; an .env.example with demonstration values can document the required settings.
| Environment | Example NUXT_PUBLIC_SITE_URL value |
|---|---|
| Local development | http://localhost:3000 |
| Staging | https://staging.your-domain.com |
| Production | https://www.your-domain.com |
For this example, use the site's origin: the protocol and hostname, plus a port when needed. Include http:// or https://, and omit page paths, query parameters, and fragments. Use the public HTTPS address visitors actually use in production, rather than an internal container name or port. If your canonical hostname has no www prefix, use that hostname consistently.
For example, a site URL of https://www.your-domain.com and a route path of /about produce the canonical URL https://www.your-domain.com/about. The setting tells the metadata code which address to publish; it does not register a domain, configure DNS or TLS, or change the server's listening address. Hosting below a path such as /studio/ also requires coordinating Nuxt's base URL and canonical URL construction beyond this root-hosted example.
For the built production server, set NUXT_PUBLIC_SITE_URL in your hosting platform's environment settings or container environment. The production Node.js process does not automatically load the project's .env file. Supply the value when the process starts, and restart or recreate the service after changing it.
How Docker Compose supplies the value
The handbook's local Compose file reads a variable named SITE_URL and passes it into the container under Nuxt's required name. Put this setting in a .env file beside compose.yaml, or supply it through the shell running Compose:
# .env beside compose.yaml, for Docker Compose interpolation
SITE_URL=https://www.your-domain.comThis is input for Compose's variable substitution. When the Nuxt project and Compose file share a directory, the same .env file can contain both variables, but they have different consumers: Nuxt reads NUXT_PUBLIC_SITE_URL for local development, and Compose reads SITE_URL for the mapping below.
environment:
NUXT_PUBLIC_SITE_URL: ${SITE_URL:-http://localhost:3000}The left side is the environment variable created inside the container. The right side substitutes SITE_URL, falling back to localhost when it is unset or empty. A Compose .env entry is not automatically injected into a container; this environment mapping performs that step. The production Compose example later in the guide requires SITE_URL explicitly so a missing setting cannot silently use localhost.
After updating the Compose setting, run docker compose up -d to apply the changed container configuration. Inspect the served page's canonical link to confirm the public hostname. See the Nuxt runtime configuration documentation for environment variable naming and deployment behavior.
app/pages/index.vue → /
<script setup lang="ts">
usePageSeo('Home', 'A small studio building thoughtful web experiences.')
</script>
<template>
<section class="hero">
<p class="eyebrow">Small team. Clear ideas.</p>
<h1>Build something useful for the web.</h1>
<p>Explore our studio, meet the team, and start a conversation.</p>
<NuxtLink class="button" to="/about">Meet the studio</NuxtLink>
</section>
</template>Nuxt maps index.vue to the root URL. The setup block registers this page's metadata, while the template supplies a single primary heading and a link to the About page. The hero classes control presentation without changing routing behavior.
app/pages/about.vue → /about
<script setup lang="ts">
usePageSeo('About', 'Meet the team behind Studio Web.')
const values: string[] = ['Accessible interfaces', 'Fast pages', 'Simple solutions']
</script>
<template>
<section>
<h1>About our studio</h1>
<p>We make small websites with care for the people using them.</p>
<ul><li v-for="value in values" :key="value">{{ value }}</li></ul>
<NuxtLink to="/contact">Talk to us</NuxtLink>
</section>
</template>The typed array provides the content for the values list. v-for renders one list item per value, and :key gives Vue a stable identity for each item. These strings are unique in this example; use stable IDs when rendering editable records.
app/pages/contact.vue → /contact
<script setup lang="ts">
usePageSeo('Contact', 'Get in touch with Studio Web about your next project.')
</script>
<template>
<section>
<h1>Contact us</h1>
<p>Tell us what you would like to build.</p>
<a href="mailto:hello@example.com">hello@example.com</a>
<p>This demonstration address must be replaced before launch.</p>
</section>
</template>This page registers its own metadata and presents an ordinary email link. The mailto: scheme asks the user's device to open an email application. It does not submit a request to Nuxt or guarantee that an email client is configured.
The contact page opens an email client; it has no form or message-storage backend. Replace the demonstration email before launch. Add an owned social preview image with an absolute ogImage URL if you want richer previews.
For this three-page site, create public/robots.txt with User-agent: * and Allow: / on separate lines. For a larger site, generate a sitemap from public routes and link it from robots.txt. Robots rules are crawler guidance, never access control. Semantic headings, descriptive links, fast responses, and useful content matter alongside metadata; SSR alone does not guarantee rankings.
public/robots.txt
User-agent: *
Allow: /The wildcard addresses all compliant crawlers and the allow rule permits crawling site paths. Save this plain-text file under public; it will be available at /robots.txt. A sitemap is a separate list of public URLs and is an optional extension for this small tutorial.
Stage 6: Responsive light/dark styles
Action: replace the empty app/assets/css/main.css created earlier with the complete stylesheet below. A CSS rule selects elements and gives them properties. A class selector such as .headerbar matches a template's class attribute; a selector such as :root[data-theme="dark"] matches the HTML element when its attribute has that value.
/* app/assets/css/main.css */
:root {
color-scheme: light;
--background: #f8fafc;
--surface: #ffffff;
--text: #172033;
--accent: #075c48;
--border: #cbd5e1;
}
:root[data-theme="dark"] {
color-scheme: dark;
--background: #101827;
--surface: #1e293b;
--text: #f1f5f9;
--accent: #6ee7b7;
--border: #64748b;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--text); font: 1rem/1.6 system-ui, sans-serif; }
a { color: var(--accent); text-underline-offset: .2em; }
button, .button { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: .5rem; padding: .6rem 1rem; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.shell { max-width: 70rem; margin: auto; padding: 0 1.25rem; }
.headerbar { display: flex; align-items: center; flex-wrap: wrap; gap: 1.5rem; padding: 1.25rem 0; border-bottom: 1px solid var(--border); }
.brand { font-weight: 750; }
nav { display: flex; flex-wrap: wrap; gap: 1rem; margin-right: auto; }
nav .router-link-exact-active { font-weight: 750; text-decoration-thickness: 3px; }
main { min-height: 65vh; padding: 3rem 0; }
.hero { max-width: 48rem; padding: 3rem 0; }
h1 { font-size: clamp(2rem, 5vw, 3.75rem); line-height: 1.15; }
.eyebrow { font-weight: 700; }
.button { display: inline-block; }
footer { padding: 2rem 0; border-top: 1px solid var(--border); }
.skip-link { position: absolute; top: -10rem; }
.skip-link:focus { top: 1rem; background: var(--surface); padding: 1rem; }
@media (max-width: 36rem) {
.headerbar { gap: 1rem; }
nav { order: 3; width: 100%; }
.headerbar button { margin-left: auto; }
}The root variables define the light palette; the dark-theme selector overrides those values. Shared rules consume the variables, so changing one HTML attribute updates the entire palette. Flexbox arranges the header, the media query changes its narrow-screen layout, and clamp scales the main heading within minimum and maximum sizes.
CSS custom properties keep the palette consistent. color-scheme also informs native controls. The header wraps on narrow screens and visible focus styles work in both themes. Check contrast again when changing colors, including hover and focus states.
Checkpoint: save every application file, run npm run dev from studio-web, and open its local URL. You should see the landing headline, three navigation links, and a Light button. Visit About and Contact, toggle to Dark, then reload: the palette should remain dark. Narrow the browser window to check the wrapping header. If a file cannot be found, compare its exact spelling and folder with Stage 2; if styles are missing, check the configured CSS path.
Stage 7: SSR & hydration
This stage explains the working app; it requires no file changes. Rendering means producing the interface from components and state. Server-Side Rendering (SSR) produces HTML before sending the response. Hydration attaches Vue's behavior to that existing HTML in the browser. Serialized state is state converted into a transferable data format so both sides start with matching values.
sequenceDiagram
participant Browser
participant Nuxt as Nuxt / Nitro
participant Store as Request-scoped Pinia
Browser->>Nuxt: GET /about with theme cookie
Nuxt->>Store: Initialize validated theme
Store-->>Nuxt: Theme state
Nuxt-->>Browser: HTML + metadata + serialized state
Browser->>Browser: Hydrate matching Vue tree
Browser->>Browser: Toggle theme and update cookieRead the diagram from top to bottom. The browser first sends a request containing its cookie. Nuxt initializes the request's Pinia store and renders HTML using that theme. The response includes both visible content and state for hydration. The browser then attaches Vue behavior; a later button click updates reactive state and the preference cookie.
On a direct request, Nuxt renders the page and metadata on the server. The browser displays that HTML, then Vue hydrates it by attaching behavior using serialized state. Later internal navigation can update pages without loading a whole new document.
- Invariant: initial server and client markup agree. Do not read
localStorage,window, random numbers, or the current time to choose initial markup. - Isolation: create stores inside setup or an appropriate Nuxt context. Never put a mutable user store at module scope on the server.
- Browser-only work: use
onMountedfor DOM APIs andClientOnlyfor widgets that cannot render on the server. - Theme agreement: the request cookie seeds server state; Pinia's Nuxt integration transfers that state to hydration. Both the button and HTML attribute reflect it.
| Mode | HTML created | Tradeoff |
|---|---|---|
| SSR (this example) | On each request | Can respect cookies; requires a running server. |
| Prerendering | At build time | Simple static hosting; cannot personalize initial HTML from request cookies. |
| Client rendering | In the browser | Useful for some private tools; initial content depends on JavaScript. |
Do not switch this example to static generation and expect its cookie-based first render to keep working unchanged. A static version needs a different initial-theme strategy. SSR responses personalized by a cookie must not be served from a shared cache as if they were identical.
Stage 8: Server data & configuration
Optional exercise: the three-page website is complete without this stage. This extension adds a fourth page at /status and a JavaScript Object Notation (JSON) endpoint at /api/status. An Application Programming Interface (API) endpoint returns data for software to consume; a page returns a user-facing document. JSON represents data using objects, arrays, and primitive values such as strings.
The complete three-page example needs no API. When adding one, use Nuxt's SSR-aware data composables to transfer server-fetched results into the client payload rather than fetching the same data independently during hydration.
server/api/status.get.ts
// server/api/status.get.ts
export default defineEventHandler(() => ({ message: 'Studio is online' }))Create server/api at the project root, outside app. The .get suffix restricts this handler to GET requests. defineEventHandler registers the function whose returned object becomes the JSON response. Open /api/status in the browser; expect an object containing the message “Studio is online”.
app/pages/status.vue
<script setup lang="ts">
usePageSeo('Status', 'Check whether the studio service is responding.')
const { data, status, error } = await useFetch('/api/status', {
lazy: true,
})
</script>
<template>
<section>
<h1>Service status</h1>
<p v-if="status === 'pending' || status === 'idle'" role="status">
Loading status…
</p>
<p v-else-if="error" role="alert">Could not load the status. Try reloading.</p>
<p v-else>{{ data?.message }}</p>
</section>
</template>await lets setup wait for the composable's initial work. useFetch returns reactive data, status, and error values; object destructuring assigns those named results to variables. The lazy option lets client navigation continue while a response is pending. Server rendering still awaits the initial fetch. v-if and v-else-if choose the loading or failure message, while v-else shows the result. The optional chaining operator in data?.message safely handles a missing result.
Checkpoint: open /status directly and expect “Studio is online”. To observe the loading state during client navigation, temporarily add a /status NuxtLink to the header and use network throttling in developer tools. To observe failure, temporarily change the fetch URL to /api/missing, reload, and then restore /api/status. A loading message may be too brief to notice on a fast connection.
Keep private runtime configuration outside runtimeConfig.public; everything under public is browser-visible. TypeScript cannot validate incoming JSON, cookies, or form submissions. Validate those at runtime and enforce authorization on the server. Avoid rendering untrusted HTML with v-html.
Stage 9: Check the application
Action: stop the development server first, so it does not compete for the production server's port. Run these commands from the project root. A type-check or build failure stops this checkpoint; read the named file and line in the error, correct it, and rerun the failing command before starting the server.
npm run typecheck
npm run build
node .output/server/index.mjs
# In another terminal:
curl -fsS http://localhost:3000/about
curl -fsS -H 'Cookie: studio-theme=dark' http://localhost:3000/Run type checking and build first, then start the generated Node.js server. Leave that process running and execute the curl commands in a second terminal. The first request checks a direct About-page response; the second sends a dark-theme cookie so you can inspect the server-rendered theme. The -f option makes HTTP error responses fail the command.
- Open all three URLs directly and through the header. Use Back/Forward and confirm the active navigation link.
- Toggle the theme using keyboard and pointer. Navigate and reload; the preference should persist. A fresh browser profile should start light.
- Inspect raw HTML: the route heading, description, canonical URL, and theme attribute must exist before JavaScript runs.
- Check the console for hydration warnings. Test invalid
studio-themecookies; they should render light. - Check a narrow viewport, keyboard focus, skip link, button announcement, and both color palettes.
For an evolving product, add browser tests for navigation, theme persistence, and hydration errors. The CI smoke checks below cover server HTML, not interactive browser behavior.
Inspect the result in your browser
- Open the browser's developer tools from its menu. In Chrome or Edge, right-click the page and choose Inspect. Select Console and reload; there should be no hydration-mismatch warnings or application errors.
- In Application → Storage → Cookies, select the local site. Toggle the theme and inspect studio-theme: it should change between light and dark. Edit it to an invalid value and reload; the app should fall back to light.
- Use View Page Source from the browser menu or page context menu to inspect the original server response, rather than only the live Elements tree. Search for the page heading, description, rel="canonical", and data-theme.
- At /about, expect a title containing About, a canonical URL ending in /about, and the About heading in the returned HTML. With the dark cookie, expect data-theme="dark" before client-side code changes the document.
- Press Tab to reach the skip link and navigation, and use Enter or Space on the theme button. Try a narrow window and a fresh private-browsing session. The fresh session should start light.
Expected result: type checking and the build exit successfully, both curl requests return HTML, navigation works, and the theme survives reload. An HTTP failure means the server or route needs investigation; valid HTML alone does not prove that browser interactions work.
Stage 10: Docker deployment
Goal: run the same built application in a container. An image is a packaged filesystem and launch configuration; a container is a running instance of it. Docker's build context is the directory whose files are available to COPY. Compose describes how a service runs, including its image, ports, and environment.
Prepare: install Docker Desktop or Docker Engine with Compose using the instructions for your operating system. Start Docker Desktop if applicable, and use Linux containers. Stop the local Node.js server before publishing container port 3000.
docker version
docker compose versionExpect client and server information from docker version and a Compose version from the second command. “Cannot connect to the Docker daemon” means the engine is not running or your account cannot access it. Fix that before building the image. Save Dockerfile, .dockerignore, and compose.yaml in studio-web as shown below; YAML indentation uses spaces.
# Dockerfile
FROM node:24-alpine AS build
WORKDIR /app
COPY package.json package-lock.json ./
RUN npm ci
COPY . .
RUN npm run build
FROM node:24-alpine AS runtime
WORKDIR /app
ENV NODE_ENV=production
ENV NITRO_HOST=0.0.0.0
ENV NITRO_PORT=3000
COPY --from=build --chown=node:node /app/.output ./.output
USER node
EXPOSE 3000
CMD ["node", ".output/server/index.mjs"]Each FROM begins a stage. Copying dependency manifests before source files lets Docker reuse the install layer when only application code changes. npm ci installs from the lockfile, then the build creates .output. The final stage starts from a fresh image, copies that output with appropriate ownership, and launches the Node server. EXPOSE documents the port; it does not publish it to the host.
The build stage installs locked dependencies and compiles Nuxt. The runtime stage copies Nitro's self-contained output and runs as an unprivileged user. Listen on all container interfaces; the host's published port can still be restricted to loopback. Pin a verified base-image digest for reproducible releases and update it deliberately.
.dockerignore
node_modules
.nuxt
.output
.git
.env
.env.*
npm-debug.log*These patterns exclude local dependencies, generated output, Git history, and environment files from the build context. Docker therefore installs dependencies inside its build environment instead of copying a potentially incompatible local installation. Review these patterns if you later introduce files that the build genuinely requires.
compose.yaml
services:
web:
image: studio-web:local
build: .
ports:
- "127.0.0.1:3000:3000"
environment:
NUXT_PUBLIC_SITE_URL: ${SITE_URL:-http://localhost:3000}
restart: unless-stopped
init: trueThe web service builds from the current directory and names the resulting image. The port mapping exposes container port 3000 only on the host's loopback interface. SITE_URL supplies the public origin, with a local fallback. The restart policy helps recover from process exits, and init improves signal forwarding and child-process cleanup.
docker compose up --build -d
docker compose logs -f web
docker compose downup --build -d builds and starts the service in the background. logs -f follows its output; Ctrl+C stops following logs without stopping the container. down stops and removes the Compose containers and network.
Visit localhost:3000. Place a TLS reverse proxy in front for production. Supply runtime secrets through your deployment system; this image excludes local environment files. No database volume is needed because this app stores only a theme cookie in the browser.
Checkpoint: run the Compose commands one at a time. After up completes, open http://localhost:3000 and repeat navigation and theme checks. Follow logs in a terminal if startup fails. A bind error usually means another process still occupies port 3000. Stop following logs with Ctrl+C; keep the service running until you are ready to use down.
Stage 11: CI/CD & rollback
Put the tutorial project on GitHub
This stage requires Git installed locally and a GitHub account. Git records source versions; GitHub hosts the repository and runs workflows. Create an empty repository named studio-web on GitHub, without an initial README, so it does not conflict with the local history. Open a terminal in your tutorial project and replace YOUR_USERNAME in the commands below.
Before committing, inspect the scaffold's .gitignore and ensure it excludes node_modules, .nuxt, .output, .env, and .env.*. Add those patterns if missing, keeping any intended exception for .env.example. Save the workflow below as .github/workflows/ci.yml before running the commands. Authentication for git push uses your configured GitHub credential manager or SSH setup; a password prompt is not a request to put credentials into source files.
git init
git branch -M main
git add .
git commit -m "Create Studio Web tutorial app"
git remote add origin https://github.com/YOUR_USERNAME/studio-web.git
git push -u origin maingit init creates the repository if the scaffold did not already initialize it. The branch command names the current branch main. add stages files, commit records a snapshot, remote add connects it to GitHub, and push uploads it. If Git asks for your author name and email, configure them with git config as instructed by Git. If origin already exists, inspect git remote -v and use the correct existing remote rather than adding a duplicate.
Continuous integration checks every proposed change. Continuous delivery publishes a deployable artifact after checks pass. Continuous deployment also promotes that artifact automatically. The workflow below checks pull requests and publishes commit-tagged images from main; production promotion is a separate, explicit step.
# .github/workflows/ci.yml
name: Web checks and image
on:
pull_request:
push:
branches: [main]
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: '24'
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm run build
- name: Smoke-test SSR routes
shell: bash
run: |
node .output/server/index.mjs > /tmp/studio.log 2>&1 &
pid=$!
trap 'kill "$pid"' EXIT
for attempt in {1..30}; do
if curl -fsS http://localhost:3000/ > /dev/null; then break; fi
sleep 1
done
curl -fsS http://localhost:3000/ | grep -q 'Build something useful'
curl -fsS http://localhost:3000/about | grep -q 'About our studio'
curl -fsS http://localhost:3000/contact | grep -q 'Contact us'
curl -fsS -H 'Cookie: studio-theme=dark' http://localhost:3000/ | grep -q 'data-theme="dark"'
publish:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: check
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v6
- name: Build and publish commit image
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
image="ghcr.io/${GITHUB_REPOSITORY,,}:${GITHUB_SHA}"
echo "$GH_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
docker build -t "$image" .
docker push "$image"The check job installs locked dependencies, checks types, builds, and starts the production server for HTTP smoke checks. Its shell trap stops the server when the step exits. The publish job depends on those checks and runs only for pushes to main. It authenticates to GHCR, builds the Docker image, and publishes a tag based on the commit SHA. Publishing an image does not update a running production service.
This example uses GitHub-hosted Linux runners and GHCR. Restrict main with required checks. Action tags are readable teaching defaults; pin reviewed commit SHAs in production. Publishing permissions exist only in the publish job. Fork pull requests run checks without registry credentials. Add browser tests before publishing when the application grows.
A job is a group of steps on a runner, the computer executing the workflow. needs: check prevents publishing before verification succeeds. GITHUB_TOKEN is a temporary credential supplied by GitHub Actions, so you do not create a repository secret for this example. GitHub Container Registry (GHCR) stores the image. The image name uses your repository owner and name, converted to lowercase, followed by the source commit SHA, the hash identifying the source revision.
Checkpoint: after pushing main, open the repository's Actions tab and select Web checks and image. Both jobs should finish green. Open a failed step to read its log. In your GitHub account or organization's Packages area, find the image and its commit tag. An organization may require permission to create packages; a denied publish does not mean the application build failed. Configure required checks in your repository's branch rules or rulesets before accepting other contributors' changes.
Prepare a production host
A production host is a computer that stays online and can receive visitors' requests. This deployment path uses a Linux host with Docker Engine and Compose installed, plus Caddy installed as a system service on that same host. Connect using your provider's console or SSH and create a directory for compose.production.yaml. Installation and access procedures depend on the provider and operating system; follow the linked official instructions before continuing.
Choose a real hostname you control. In your domain provider's Domain Name System (DNS) settings, point its A record at the host's public Internet Protocol version 4 (IPv4) address, and set an AAAA record only if Internet Protocol version 6 (IPv6) is configured and reachable. Allow inbound HTTP port 80 and HTTPS port 443 through the provider and host firewalls. Keep application port 3000 restricted to loopback as in Compose. Transport Layer Security (TLS) secures HTTPS connections; a reverse proxy accepts visitors' requests and forwards them to the private application port.
Replace owner/repo and COMMIT_SHA in the release example with the published lowercase image name and successful workflow's full commit SHA. Public GHCR images allow anonymous pulls. For a private image, create a GitHub personal access token (classic) with read:packages and access to that package, including organization SSO authorization if required, then log in on the host:
# On the Linux deployment host; enter a read:packages token at the prompt.
docker login ghcr.io -u YOUR_GITHUB_USERNAMEPaste the token into Docker's password prompt, not into a command, Git file, or tutorial snippet. The host account must have access to the package. See GitHub's container registry instructions for token and package permissions.
Production host configuration
# compose.production.yaml on the deployment host
services:
web:
image: ${IMAGE:?Set IMAGE to a published commit tag}
ports:
- "127.0.0.1:3000:3000"
environment:
NUXT_PUBLIC_SITE_URL: ${SITE_URL:?Set the public HTTPS origin}
restart: unless-stopped
init: trueThis Compose file pulls an existing release image rather than building source on the host. The required-variable expressions fail early if IMAGE or SITE_URL is missing. Keep the application port private behind the host's HTTPS proxy and supply the public origin that visitors actually use.
# On a Linux Docker host; replace owner/repo and the commit SHA.
# Authenticate with a read:packages token if the image is private.
export IMAGE=ghcr.io/owner/repo:COMMIT_SHA
export SITE_URL=https://studio.example.com
docker compose -f compose.production.yaml pull
docker compose -f compose.production.yaml up -d
curl -fsS http://127.0.0.1:3000/about
# Rollback: set IMAGE to the previous known-good commit, then repeat
# pull, up -d, and the health check.Run these commands on the deployment host after replacing the example values. Pull downloads the selected release, and up recreates the service when its configuration or image changes. The curl request checks a local application route. Rollback uses the same procedure with the previously recorded image; also verify the public HTTPS URL after either operation.
export sets a variable for commands launched from the current Bash session; closing that session loses those assignments. Save IMAGE and SITE_URL in a .env beside compose.production.yaml if you want Compose to read them in future sessions, and update IMAGE deliberately for each release. The local curl check must succeed before configuring the public proxy.
Connect the domain through HTTPS
Install Caddy using its official platform instructions. For a Linux package installation with its system service, edit /etc/caddy/Caddyfile using your host's editor and administrative permissions. On a fresh dedicated tutorial host, use the following file with your actual hostname. Preserve existing site blocks if the host already serves other applications.
# /etc/caddy/Caddyfile on a host with Caddy installed as a service
studio.example.com {
reverse_proxy 127.0.0.1:3000
}The hostname selects the public site, while reverse_proxy forwards traffic to Nuxt on the same host. Caddy manages HTTPS certificates for eligible public names when DNS and network access are correct. This is a host-installed proxy: 127.0.0.1 reaches the host-published application port. A proxy in another container would need a different network address.
sudo caddy validate --config /etc/caddy/Caddyfile --adapter caddyfile
sudo systemctl reload caddy
curl -fsS https://studio.example.com/aboutValidation checks configuration before reload; run the next command only if it succeeds. Reload applies the file through the existing service, and curl checks the public HTTPS route. If HTTPS fails, check DNS, reachable ports, service status, and Caddy logs using the Caddy service documentation. If the response is 502, check that the app is listening on the expected host port.
Release checkpoint: visit the real HTTPS URL from another device, test all three routes and the theme, and inspect the canonical origin. Record the deployed image and previous known-good image. Rollback means redeploying that previous image, then repeating the local and public checks; it is not reverting files inside a running container.
Record the previous release before promotion. Check all public routes through the HTTPS proxy after deployment, including the canonical origin. Commit tags identify source revisions but registry tags can be overwritten; use the published image digest when immutability is required. A single-container Compose update can interrupt requests. Use a platform with rolling or blue/green deployment when availability requires it.
To automate promotion, have your deployment platform pull the approved image digest after the publish job, using a protected production environment and narrowly scoped credentials. Keep environment-specific deployment configuration on the host or platform. Database migrations, if introduced later, need an independent compatibility and rollback plan.
Troubleshooting
| Symptom | Check |
|---|---|
| Pages do not appear | Replace the starter app with NuxtLayout/NuxtPage and place pages under app/pages. |
| Unknown store or component | Enable @pinia/nuxt, check file locations/imports, and restart the dev server after config changes. |
| Theme resets on reload | Inspect the cookie, its path, and browser cookie policy. Use the same hostname while testing. |
| Wrong theme or hydration mismatch | Check cookie-dependent shared caches, module-level state, and browser-only initial-state reads. |
| Canonical URL contains localhost | Set NUXT_PUBLIC_SITE_URL in the running container and recreate it. |
| Container is unreachable | Check logs, published ports, and NITRO_HOST. Do not use vite preview as the production server. |
| CI npm ci fails | Regenerate and commit the lockfile after dependency changes; do not replace the check with an unlocked install. |
Official references
- Nuxt 4 documentation — setup, conventions, and rendering.
- Vite guide — development and build tooling.
- TypeScript handbook — types and narrowing.
- Pinia with Nuxt — module setup, store discovery, and SSR integration.
- Nuxt useCookie — request-aware persistence.
- Nuxt SEO and metadata — head management.
- Nuxt deployment — production server output.
- Docker multi-stage builds — separating build and runtime.
- GitHub Actions image publishing — registry authentication and release workflows.