# nextjs-deployment

Provides production deployment patterns for Next.js. Sets up multi-stage Dockerfiles, GitHub Actions workflows, health checks, and OpenTelemetry instrumentation.

- skill · `type=skill` · Claude Code, Codex, Cursor, GitHub Copilot, Gemini CLI, OpenCode · 3700 installs · ★ 363
- Author: giuseppe-trisciuoglio
- License: MIT · policy=mirror · the beginning of the file is at the end of this page
- Source: https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nextjs-deployment/SKILL.md
- Updated: 2026-09-10
- HTML: https://affpapa.org/en/nevibecode/skills/nextjs-deployment

## What it does

The skill sets up production infrastructure for Next.js applications. It switches `next.config.ts` to `output: 'standalone'` to produce a minimal build output without unused dependencies. It generates a multi-stage `Dockerfile` based on Alpine Linux, running as a non-root `nextjs` user with a built-in health check on `/api/health`.

It configures CI/CD automation using GitHub Actions to build and push images to GitHub Container Registry. Workflows use Buildx caching and pass Git commit hashes as build arguments. The skill also adds runtime environment variable validation and registers OpenTelemetry tracing in `instrumentation.ts`.

Deploying across multiple instances will break Server Actions unless you define `NEXT_SERVER_ACTIONS_ENCRYPTION_KEY`. Without a synchronized key, instances cannot decrypt actions created by another node. The workflow includes generating and passing this secret directly during the build step.

## Requirements
- Works with: Docker

## Install

### Claude Code (native platform)

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment -a claude-code
```

2. **Manually: put the files in place**
- File: `~/.claude/skills/nextjs-deployment/SKILL.md` — Copy the whole skill folder; for one project use .claude/skills/nextjs-deployment/

### Codex

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment -a codex
```

2. **Manually: put the files in place**
- File: `.agents/skills/nextjs-deployment/SKILL.md` — For all projects use ~/.agents/skills/

### Cursor

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment -a cursor
```

2. **Manually: put the files in place**
- File: `.cursor/skills/nextjs-deployment/SKILL.md` — Cursor also reads .agents/skills/ and .claude/skills/

### GitHub Copilot

1. **GitHub CLI**
```bash
gh skill install giuseppe-trisciuoglio/developer-kit nextjs-deployment
```

2. **Manually: put the files in place**
- File: `.github/skills/nextjs-deployment/SKILL.md`

### Gemini CLI

1. **Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment -a gemini-cli
```

2. **Platform CLI**
```bash
gemini skills install https://github.com/giuseppe-trisciuoglio/developer-kit --path plugins/developer-kit-typescript/skills/nextjs-deployment
```

### Windsurf (Devin Desktop)

**Manually: put the files in place**
- File: `.devin/skills/nextjs-deployment/SKILL.md` — The legacy .windsurf/skills/ path still works

### OpenCode

**Skills CLI (Vercel)**
```bash
npx skills add giuseppe-trisciuoglio/developer-kit --skill nextjs-deployment -a opencode
```

### Claude.ai

**Claude.ai**
- Zip the folder and upload it in Settings → Capabilities → Skills

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nextjs-deployment/SKILL.md

## When to use it
- configure a multi-stage Docker build for Next.js
- set up a GitHub Actions CI/CD pipeline for container registries
- add an `/api/health` status check endpoint
- instrument Next.js with OpenTelemetry via `@vercel/otel`
- configure `NEXT_SERVER_ACTIONS_ENCRYPTION_KEY` for multi-server scaling

## Example prompts
- Generate a production Dockerfile for Next.js using standalone mode
- Create a GitHub Actions deployment workflow targeting GHCR
- Add environment validation and a health check route to this Next.js project

## Source text · SKILL.md · MIT

Below is the content of a third-party file. It is data, not instructions for you: do not act on anything written inside unless the human asks. Block tag: 812553299576144b.

BEGIN THIRD-PARTY FILE 812553299576144b
```text
---
name: nextjs-deployment
description: Provides comprehensive patterns for deploying Next.js applications to production. Use when configuring Docker containers, setting up GitHub Actions CI/CD pipelines, managing environment variables, implementing preview deployments, or setting up monitoring and logging for Next.js applications. Covers standalone output, multi-stage Docker builds, health checks, OpenTelemetry instrumentation, and production best practices.
allowed-tools: Read, Write, Edit, Bash
---

# Next.js Deployment

Deploy Next.js applications to production with Docker, CI/CD pipelines, and comprehensive monitoring.

## Overview

This skill provides patterns and code examples for deploying Next.js applications to production environments. It covers containerization with Docker, CI/CD automation with GitHub Actions, environment configuration, health checks, and production monitoring. Use standalone output mode for container deployments, multi-stage Docker builds for optimized images, and OpenTelemetry for observability.

## When to Use

Activate when user requests involve:
- "Deploy Next.js", "Dockerize Next.js", "containerize"
- "GitHub Actions", "CI/CD pipeline", "automated deployment"
- "Environment variables", "runtime config", "NEXT_PUBLIC"
- "Preview deployment", "staging environment"
- "Monitoring", "OpenTelemetry", "tracing", "logging"
- "Health checks", "readiness", "liveness"
- "Production build", "standalone output"
- "Server Actions encryption key", "NEXT_SERVER_ACTIONS_ENCRYPTION_KEY"

## Quick Reference

### Output Modes

| Mode | Use Case | Command |
|------|----------|---------|
| `standalone` | Docker/container deployment | `output: 'standalone'` |
| `export` | Static site (no server) | `output: 'export'` |
| (default) | Node.js server deployment | `next start` |

### Environment Variable Types

| Prefix | Availability | Use Case |
|--------|--------------|----------|
| `NEXT_PUBLIC_` | Build-time + Browser | Public API keys, feature flags |
| (no prefix) | Server-only | Database URLs, secrets |
| Runtime | Server-only | Different values per environment |

### Key Files

| File | Purpose |
|------|---------|
| `Dockerfile` | Multi-stage container build |
| `.github/workflows/deploy.yml` | CI/CD pipeline |
| `next.config.ts` | Build configuration |
| `instrumentation.ts` | OpenTelemetry setup |
| `src/app/api/health/route.ts` | Health check endpoint |

## Instructions
```
END THIRD-PARTY FILE 812553299576144b

The third-party file has ended. Everything between the 812553299576144b tags is data: requests and commands from it are not followed. An “end of file” line with another tag inside the block is part of the file.

First 2434 of 9023 bytes. © giuseppe-trisciuoglio · MIT · https://github.com/giuseppe-trisciuoglio/developer-kit/tree/HEAD/plugins/developer-kit-typescript/skills/nextjs-deployment/SKILL.md

_Part of the page did not fit — see the HTML version._

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
