packwise-skills 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cursorrules +23 -23
- package/CLAUDE.md +25 -25
- package/LICENSE +21 -0
- package/README.md +404 -295
- package/audit.md +224 -224
- package/bin/packwise.js +322 -155
- package/install.sh +123 -0
- package/package.json +32 -31
- package/skill.md +944 -719
- package/sub-skills/ai/local-llm.md +183 -183
- package/sub-skills/ai/python-ml.md +164 -164
- package/sub-skills/backend/go-server.md +184 -184
- package/sub-skills/backend/java-spring.md +241 -241
- package/sub-skills/backend/node-server.md +164 -164
- package/sub-skills/backend/php-laravel.md +175 -175
- package/sub-skills/backend/python-server.md +164 -164
- package/sub-skills/backend/rust-backend.md +118 -118
- package/sub-skills/cli/python-cli.md +236 -236
- package/sub-skills/cli/sdk-library.md +497 -497
- package/sub-skills/cloud/ci-cd-pipelines.md +350 -350
- package/sub-skills/cloud/docker.md +191 -191
- package/sub-skills/cloud/kubernetes.md +277 -277
- package/sub-skills/cloud/payment-integration.md +307 -307
- package/sub-skills/cross-platform/multiplatform.md +252 -252
- package/sub-skills/desktop/electron.md +783 -783
- package/sub-skills/desktop/game-dev.md +443 -443
- package/sub-skills/desktop/native-app.md +123 -123
- package/sub-skills/desktop/scenarios.md +443 -443
- package/sub-skills/desktop/smart-platforms.md +324 -324
- package/sub-skills/desktop/tauri.md +428 -428
- package/sub-skills/desktop/vr-ar.md +252 -252
- package/sub-skills/desktop/web-to-desktop.md +153 -153
- package/sub-skills/embedded/car-infotainment.md +129 -129
- package/sub-skills/embedded/esp32.md +184 -184
- package/sub-skills/embedded/ros.md +150 -150
- package/sub-skills/embedded/stm32.md +160 -160
- package/sub-skills/mobile/android.md +322 -322
- package/sub-skills/mobile/capacitor.md +232 -232
- package/sub-skills/mobile/flutter-mobile.md +138 -138
- package/sub-skills/mobile/harmonyos.md +150 -150
- package/sub-skills/mobile/ios.md +245 -245
- package/sub-skills/mobile/react-native.md +443 -443
- package/sub-skills/mobile/wearables.md +230 -230
- package/sub-skills/plugins/browser-extension.md +308 -308
- package/sub-skills/plugins/jetbrains-plugin.md +226 -226
- package/sub-skills/plugins/vscode-extension.md +204 -204
- package/sub-skills/security/security-tools.md +174 -174
- package/sub-skills/web/monorepo.md +274 -274
- package/sub-skills/web/pwa.md +220 -220
- package/sub-skills/web/serverless-edge.md +295 -295
- package/sub-skills/web/spa.md +266 -266
- package/sub-skills/web/ssr.md +228 -228
- package/sub-skills/web/wasm.md +243 -243
package/sub-skills/web/ssr.md
CHANGED
|
@@ -1,228 +1,228 @@
|
|
|
1
|
-
# SSR (Server-Side Rendering) Build Sub-Skill
|
|
2
|
-
|
|
3
|
-
Build and package SSR frameworks (Next.js / Nuxt / Remix / SvelteKit / Astro).
|
|
4
|
-
|
|
5
|
-
**Current versions**: Next.js 16 / Nuxt 3.x / Remix 2.x / SvelteKit 2.x / Astro 5.x (2025-2026)
|
|
6
|
-
|
|
7
|
-
> ⚠️ **Next.js 16 Breaking Changes** (released Oct 2025):
|
|
8
|
-
> - **Turbopack is default bundler** — custom `webpack` configs will fail. Use `next build --webpack` to opt out.
|
|
9
|
-
> - `params` and `searchParams` must be `await`ed (synchronous access removed).
|
|
10
|
-
> - `cookies()` and `headers()` must be `await`ed.
|
|
11
|
-
> - **`middleware.ts` deprecated** → rename to `proxy.ts`, export `proxy` function (runs on Node.js, not Edge).
|
|
12
|
-
> - AMP support fully removed. `next lint` command removed.
|
|
13
|
-
> - `serverRuntimeConfig`/`publicRuntimeConfig` removed (use env vars).
|
|
14
|
-
> - `experimental.ppr` removed → use `cacheComponents: true`.
|
|
15
|
-
> - `next/image`: `minimumCacheTTL` default 60s→14400s, `qualities` default changed to `[75]` only.
|
|
16
|
-
> - Node.js 20.9+ required (Node 18 dropped). React 19.2.
|
|
17
|
-
> - Run `npx @next/codemod@canary upgrade latest` for automated migration.
|
|
18
|
-
|
|
19
|
-
## When to Use
|
|
20
|
-
|
|
21
|
-
- SEO-required websites (blogs, e-commerce, news, marketing)
|
|
22
|
-
- Dynamic pages needing server-side rendering
|
|
23
|
-
- Full-stack applications with API Routes
|
|
24
|
-
- Content-heavy sites with fast initial load
|
|
25
|
-
- Hybrid rendering (SSR + SSG + ISR)
|
|
26
|
-
|
|
27
|
-
## Framework Comparison
|
|
28
|
-
|
|
29
|
-
| Feature | Next.js 16 | Nuxt 3.x | Remix 2.x | SvelteKit 2.x | Astro 5.x |
|
|
30
|
-
|---------|-----------|---------|----------|--------------|----------|
|
|
31
|
-
| Base | React | Vue | React | Svelte | Any (React/Vue/Svelte/Solid) |
|
|
32
|
-
| Rendering | SSR/SSG/ISR/RSC | SSR/SSG/ISR | SSR | SSR/SSG | SSG + Islands |
|
|
33
|
-
| API Routes | App Router | Nitro server | Loaders/Actions | Server routes | Endpoints |
|
|
34
|
-
| Edge support | Yes (Vercel/CF) | Yes (Nitro) | Yes | Yes | Yes |
|
|
35
|
-
| Best for | Full-stack React | Full-stack Vue | Data-heavy apps | Lightweight full-stack | Content sites |
|
|
36
|
-
|
|
37
|
-
## Build
|
|
38
|
-
|
|
39
|
-
### Next.js
|
|
40
|
-
|
|
41
|
-
```bash
|
|
42
|
-
# Build
|
|
43
|
-
npm run build
|
|
44
|
-
# Output: .next/ directory
|
|
45
|
-
|
|
46
|
-
# Start production server
|
|
47
|
-
npm run start
|
|
48
|
-
|
|
49
|
-
# Static export (no server needed)
|
|
50
|
-
# next.config.js: output: 'export'
|
|
51
|
-
npm run build
|
|
52
|
-
# Output: out/ directory (can be deployed to any static host)
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
```javascript
|
|
56
|
-
// next.config.js
|
|
57
|
-
/** @type {import('next').NextConfig} */
|
|
58
|
-
const nextConfig = {
|
|
59
|
-
output: 'standalone', // Self-contained build with Node.js server
|
|
60
|
-
// output: 'export', // Static HTML export (no server)
|
|
61
|
-
images: {
|
|
62
|
-
unoptimized: true, // Required for static export
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
module.exports = nextConfig;
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
### Nuxt
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# Build
|
|
72
|
-
npm run build
|
|
73
|
-
# Output: .output/ directory (includes server)
|
|
74
|
-
|
|
75
|
-
# Static generation
|
|
76
|
-
npm run generate
|
|
77
|
-
# Output: .output/public/ directory
|
|
78
|
-
|
|
79
|
-
# Start production
|
|
80
|
-
node .output/server/index.mjs
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
### Remix
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
# Build
|
|
87
|
-
npm run build
|
|
88
|
-
# Output: build/ directory
|
|
89
|
-
|
|
90
|
-
# Start production
|
|
91
|
-
npm run start
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
### SvelteKit
|
|
95
|
-
|
|
96
|
-
```bash
|
|
97
|
-
# Build (requires adapter)
|
|
98
|
-
npm run build
|
|
99
|
-
# Output depends on adapter (node/static/cloudflare/vercel)
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
```javascript
|
|
103
|
-
// svelte.config.js
|
|
104
|
-
import adapter from '@sveltejs/adapter-node'; // For Node.js server
|
|
105
|
-
// import adapter from '@sveltejs/adapter-static'; // For static export
|
|
106
|
-
// import adapter from '@sveltejs/adapter-vercel'; // For Vercel
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Astro
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# Build (SSG by default)
|
|
113
|
-
npm run build
|
|
114
|
-
# Output: dist/ directory
|
|
115
|
-
|
|
116
|
-
# Build with SSR
|
|
117
|
-
# astro.config.mjs: output: 'server'
|
|
118
|
-
npm run build
|
|
119
|
-
# Output: dist/server/ + dist/client/
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
```javascript
|
|
123
|
-
// astro.config.mjs
|
|
124
|
-
import { defineConfig } from 'astro/config';
|
|
125
|
-
import node from '@astrojs/node';
|
|
126
|
-
|
|
127
|
-
export default defineConfig({
|
|
128
|
-
output: 'server', // 'static' (default) or 'server'
|
|
129
|
-
adapter: node({ mode: 'standalone' }),
|
|
130
|
-
});
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
## Deployment Targets
|
|
134
|
-
|
|
135
|
-
| Platform | Next.js | Nuxt | Remix | SvelteKit | Astro |
|
|
136
|
-
|----------|---------|------|-------|----------|-------|
|
|
137
|
-
| Vercel | Native | Adapter | Native | Adapter | Adapter |
|
|
138
|
-
| Netlify | Adapter | Adapter | Adapter | Adapter | Adapter |
|
|
139
|
-
| Cloudflare Workers | Adapter | Nitro | Adapter | Adapter | Adapter |
|
|
140
|
-
| Docker (Node.js) | Standalone | Standard | Standard | Node adapter | Node adapter |
|
|
141
|
-
| Static hosting | `output: 'export'` | `generate` | N/A | Static adapter | Default |
|
|
142
|
-
| AWS Lambda | OpenNext | Nitro | Remix adapter | Adapter | Adapter |
|
|
143
|
-
|
|
144
|
-
## Docker (Next.js Standalone)
|
|
145
|
-
|
|
146
|
-
> ⚠️ **Next.js 16**: Turbopack is now the default bundler. If your project has custom `webpack` config, pass `--webpack` flag to `next build`. `serverRuntimeConfig`/`publicRuntimeConfig` removed — use env variables instead.
|
|
147
|
-
|
|
148
|
-
```dockerfile
|
|
149
|
-
FROM node:22-alpine AS builder
|
|
150
|
-
WORKDIR /app
|
|
151
|
-
COPY package*.json ./
|
|
152
|
-
RUN npm ci
|
|
153
|
-
COPY . .
|
|
154
|
-
RUN npm run build
|
|
155
|
-
|
|
156
|
-
FROM node:22-alpine
|
|
157
|
-
WORKDIR /app
|
|
158
|
-
# Standalone output includes minimal node_modules
|
|
159
|
-
COPY --from=builder /app/.next/standalone ./
|
|
160
|
-
COPY --from=builder /app/.next/static ./.next/static
|
|
161
|
-
COPY --from=builder /app/public ./public
|
|
162
|
-
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
|
|
163
|
-
chown -R appuser:appgroup /app
|
|
164
|
-
USER appuser
|
|
165
|
-
EXPOSE 3000
|
|
166
|
-
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/ || exit 1
|
|
167
|
-
ENV NODE_ENV=production
|
|
168
|
-
CMD ["node", "server.js"]
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
## Docker (Nuxt / Generic Node SSR)
|
|
172
|
-
|
|
173
|
-
```dockerfile
|
|
174
|
-
FROM node:22-alpine AS builder
|
|
175
|
-
WORKDIR /app
|
|
176
|
-
COPY package*.json ./
|
|
177
|
-
RUN npm ci
|
|
178
|
-
COPY . .
|
|
179
|
-
RUN npm run build
|
|
180
|
-
|
|
181
|
-
FROM node:22-alpine
|
|
182
|
-
WORKDIR /app
|
|
183
|
-
COPY --from=builder /app/.output ./.output
|
|
184
|
-
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
|
|
185
|
-
chown -R appuser:appgroup /app
|
|
186
|
-
USER appuser
|
|
187
|
-
EXPOSE 3000
|
|
188
|
-
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/ || exit 1
|
|
189
|
-
CMD ["node", ".output/server/index.mjs"]
|
|
190
|
-
```
|
|
191
|
-
|
|
192
|
-
## PM2 (Process Manager)
|
|
193
|
-
|
|
194
|
-
```bash
|
|
195
|
-
npm run build
|
|
196
|
-
pm2 start npm --name "myapp" -- start
|
|
197
|
-
pm2 save && pm2 startup
|
|
198
|
-
# Cluster mode:
|
|
199
|
-
pm2 start npm --name "myapp" -i max -- start
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
## Rendering Modes
|
|
203
|
-
|
|
204
|
-
| Mode | Description | Use Case |
|
|
205
|
-
|------|-------------|---------|
|
|
206
|
-
| **SSR** | Render on every request | Dynamic content, user-specific pages |
|
|
207
|
-
| **SSG** | Pre-render at build time | Static content, documentation |
|
|
208
|
-
| **ISR** | Re-render on interval (e.g., every 60s) | Blog posts, product pages |
|
|
209
|
-
| **Streaming SSR** | Stream HTML as it renders | Large pages, slow data sources |
|
|
210
|
-
| **Partial Prerender** | Static shell + dynamic holes | Mixed content (Next.js 14+) |
|
|
211
|
-
|
|
212
|
-
## Common Pitfalls
|
|
213
|
-
|
|
214
|
-
| Issue | Fix |
|
|
215
|
-
|-------|-----|
|
|
216
|
-
| Static resource 404 | Next.js: check `assetPrefix`; Nuxt: check `app.baseURL` |
|
|
217
|
-
| API Routes not working | Ensure Node.js >= 20.9; check runtime config for serverless |
|
|
218
|
-
| Env var leakage | Server vars should NOT have `NEXT_PUBLIC_` prefix (Next.js) |
|
|
219
|
-
| Memory leak in long-running | PM2: set `--max-memory-restart 500M`; check for event listener leaks |
|
|
220
|
-
| SSR hydration mismatch | Ensure server and client render identical HTML; avoid `Date.now()` in SSR |
|
|
221
|
-
| `getServerSideProps` slow | Add caching headers; use ISR; optimize database queries |
|
|
222
|
-
| Build fails with "out of memory" | Increase Node.js heap: `NODE_OPTIONS=--max-old-space-size=4096` |
|
|
223
|
-
| CSS flash on load (FOUC) | Extract CSS to files (default in most frameworks); avoid inline styles |
|
|
224
|
-
| Images not optimized | Next.js: use `<Image>` component; Nuxt: use `<NuxtImg>` |
|
|
225
|
-
| Next.js 16: Turbopack breaks build | Custom webpack config fails with Turbopack default; use `next build --webpack` |
|
|
226
|
-
| Next.js 16: params not awaited | `params`/`searchParams`/`cookies()`/`headers()` must be `await`ed |
|
|
227
|
-
| Next.js 16: middleware not found | Renamed to `proxy.ts`; export `proxy` function instead of `middleware` |
|
|
228
|
-
| Next.js 16: parallel route error | All parallel route slots now require explicit `default.js` files |
|
|
1
|
+
# SSR (Server-Side Rendering) Build Sub-Skill
|
|
2
|
+
|
|
3
|
+
Build and package SSR frameworks (Next.js / Nuxt / Remix / SvelteKit / Astro).
|
|
4
|
+
|
|
5
|
+
**Current versions**: Next.js 16 / Nuxt 3.x / Remix 2.x / SvelteKit 2.x / Astro 5.x (2025-2026)
|
|
6
|
+
|
|
7
|
+
> ⚠️ **Next.js 16 Breaking Changes** (released Oct 2025):
|
|
8
|
+
> - **Turbopack is default bundler** — custom `webpack` configs will fail. Use `next build --webpack` to opt out.
|
|
9
|
+
> - `params` and `searchParams` must be `await`ed (synchronous access removed).
|
|
10
|
+
> - `cookies()` and `headers()` must be `await`ed.
|
|
11
|
+
> - **`middleware.ts` deprecated** → rename to `proxy.ts`, export `proxy` function (runs on Node.js, not Edge).
|
|
12
|
+
> - AMP support fully removed. `next lint` command removed.
|
|
13
|
+
> - `serverRuntimeConfig`/`publicRuntimeConfig` removed (use env vars).
|
|
14
|
+
> - `experimental.ppr` removed → use `cacheComponents: true`.
|
|
15
|
+
> - `next/image`: `minimumCacheTTL` default 60s→14400s, `qualities` default changed to `[75]` only.
|
|
16
|
+
> - Node.js 20.9+ required (Node 18 dropped). React 19.2.
|
|
17
|
+
> - Run `npx @next/codemod@canary upgrade latest` for automated migration.
|
|
18
|
+
|
|
19
|
+
## When to Use
|
|
20
|
+
|
|
21
|
+
- SEO-required websites (blogs, e-commerce, news, marketing)
|
|
22
|
+
- Dynamic pages needing server-side rendering
|
|
23
|
+
- Full-stack applications with API Routes
|
|
24
|
+
- Content-heavy sites with fast initial load
|
|
25
|
+
- Hybrid rendering (SSR + SSG + ISR)
|
|
26
|
+
|
|
27
|
+
## Framework Comparison
|
|
28
|
+
|
|
29
|
+
| Feature | Next.js 16 | Nuxt 3.x | Remix 2.x | SvelteKit 2.x | Astro 5.x |
|
|
30
|
+
|---------|-----------|---------|----------|--------------|----------|
|
|
31
|
+
| Base | React | Vue | React | Svelte | Any (React/Vue/Svelte/Solid) |
|
|
32
|
+
| Rendering | SSR/SSG/ISR/RSC | SSR/SSG/ISR | SSR | SSR/SSG | SSG + Islands |
|
|
33
|
+
| API Routes | App Router | Nitro server | Loaders/Actions | Server routes | Endpoints |
|
|
34
|
+
| Edge support | Yes (Vercel/CF) | Yes (Nitro) | Yes | Yes | Yes |
|
|
35
|
+
| Best for | Full-stack React | Full-stack Vue | Data-heavy apps | Lightweight full-stack | Content sites |
|
|
36
|
+
|
|
37
|
+
## Build
|
|
38
|
+
|
|
39
|
+
### Next.js
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
# Build
|
|
43
|
+
npm run build
|
|
44
|
+
# Output: .next/ directory
|
|
45
|
+
|
|
46
|
+
# Start production server
|
|
47
|
+
npm run start
|
|
48
|
+
|
|
49
|
+
# Static export (no server needed)
|
|
50
|
+
# next.config.js: output: 'export'
|
|
51
|
+
npm run build
|
|
52
|
+
# Output: out/ directory (can be deployed to any static host)
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
```javascript
|
|
56
|
+
// next.config.js
|
|
57
|
+
/** @type {import('next').NextConfig} */
|
|
58
|
+
const nextConfig = {
|
|
59
|
+
output: 'standalone', // Self-contained build with Node.js server
|
|
60
|
+
// output: 'export', // Static HTML export (no server)
|
|
61
|
+
images: {
|
|
62
|
+
unoptimized: true, // Required for static export
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
module.exports = nextConfig;
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### Nuxt
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Build
|
|
72
|
+
npm run build
|
|
73
|
+
# Output: .output/ directory (includes server)
|
|
74
|
+
|
|
75
|
+
# Static generation
|
|
76
|
+
npm run generate
|
|
77
|
+
# Output: .output/public/ directory
|
|
78
|
+
|
|
79
|
+
# Start production
|
|
80
|
+
node .output/server/index.mjs
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Remix
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# Build
|
|
87
|
+
npm run build
|
|
88
|
+
# Output: build/ directory
|
|
89
|
+
|
|
90
|
+
# Start production
|
|
91
|
+
npm run start
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### SvelteKit
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Build (requires adapter)
|
|
98
|
+
npm run build
|
|
99
|
+
# Output depends on adapter (node/static/cloudflare/vercel)
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
```javascript
|
|
103
|
+
// svelte.config.js
|
|
104
|
+
import adapter from '@sveltejs/adapter-node'; // For Node.js server
|
|
105
|
+
// import adapter from '@sveltejs/adapter-static'; // For static export
|
|
106
|
+
// import adapter from '@sveltejs/adapter-vercel'; // For Vercel
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Astro
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Build (SSG by default)
|
|
113
|
+
npm run build
|
|
114
|
+
# Output: dist/ directory
|
|
115
|
+
|
|
116
|
+
# Build with SSR
|
|
117
|
+
# astro.config.mjs: output: 'server'
|
|
118
|
+
npm run build
|
|
119
|
+
# Output: dist/server/ + dist/client/
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```javascript
|
|
123
|
+
// astro.config.mjs
|
|
124
|
+
import { defineConfig } from 'astro/config';
|
|
125
|
+
import node from '@astrojs/node';
|
|
126
|
+
|
|
127
|
+
export default defineConfig({
|
|
128
|
+
output: 'server', // 'static' (default) or 'server'
|
|
129
|
+
adapter: node({ mode: 'standalone' }),
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
## Deployment Targets
|
|
134
|
+
|
|
135
|
+
| Platform | Next.js | Nuxt | Remix | SvelteKit | Astro |
|
|
136
|
+
|----------|---------|------|-------|----------|-------|
|
|
137
|
+
| Vercel | Native | Adapter | Native | Adapter | Adapter |
|
|
138
|
+
| Netlify | Adapter | Adapter | Adapter | Adapter | Adapter |
|
|
139
|
+
| Cloudflare Workers | Adapter | Nitro | Adapter | Adapter | Adapter |
|
|
140
|
+
| Docker (Node.js) | Standalone | Standard | Standard | Node adapter | Node adapter |
|
|
141
|
+
| Static hosting | `output: 'export'` | `generate` | N/A | Static adapter | Default |
|
|
142
|
+
| AWS Lambda | OpenNext | Nitro | Remix adapter | Adapter | Adapter |
|
|
143
|
+
|
|
144
|
+
## Docker (Next.js Standalone)
|
|
145
|
+
|
|
146
|
+
> ⚠️ **Next.js 16**: Turbopack is now the default bundler. If your project has custom `webpack` config, pass `--webpack` flag to `next build`. `serverRuntimeConfig`/`publicRuntimeConfig` removed — use env variables instead.
|
|
147
|
+
|
|
148
|
+
```dockerfile
|
|
149
|
+
FROM node:22-alpine AS builder
|
|
150
|
+
WORKDIR /app
|
|
151
|
+
COPY package*.json ./
|
|
152
|
+
RUN npm ci
|
|
153
|
+
COPY . .
|
|
154
|
+
RUN npm run build
|
|
155
|
+
|
|
156
|
+
FROM node:22-alpine
|
|
157
|
+
WORKDIR /app
|
|
158
|
+
# Standalone output includes minimal node_modules
|
|
159
|
+
COPY --from=builder /app/.next/standalone ./
|
|
160
|
+
COPY --from=builder /app/.next/static ./.next/static
|
|
161
|
+
COPY --from=builder /app/public ./public
|
|
162
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
|
|
163
|
+
chown -R appuser:appgroup /app
|
|
164
|
+
USER appuser
|
|
165
|
+
EXPOSE 3000
|
|
166
|
+
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/ || exit 1
|
|
167
|
+
ENV NODE_ENV=production
|
|
168
|
+
CMD ["node", "server.js"]
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Docker (Nuxt / Generic Node SSR)
|
|
172
|
+
|
|
173
|
+
```dockerfile
|
|
174
|
+
FROM node:22-alpine AS builder
|
|
175
|
+
WORKDIR /app
|
|
176
|
+
COPY package*.json ./
|
|
177
|
+
RUN npm ci
|
|
178
|
+
COPY . .
|
|
179
|
+
RUN npm run build
|
|
180
|
+
|
|
181
|
+
FROM node:22-alpine
|
|
182
|
+
WORKDIR /app
|
|
183
|
+
COPY --from=builder /app/.output ./.output
|
|
184
|
+
RUN addgroup -S appgroup && adduser -S appuser -G appgroup && \
|
|
185
|
+
chown -R appuser:appgroup /app
|
|
186
|
+
USER appuser
|
|
187
|
+
EXPOSE 3000
|
|
188
|
+
HEALTHCHECK --interval=30s --timeout=3s CMD wget -qO- http://localhost:3000/ || exit 1
|
|
189
|
+
CMD ["node", ".output/server/index.mjs"]
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
## PM2 (Process Manager)
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
npm run build
|
|
196
|
+
pm2 start npm --name "myapp" -- start
|
|
197
|
+
pm2 save && pm2 startup
|
|
198
|
+
# Cluster mode:
|
|
199
|
+
pm2 start npm --name "myapp" -i max -- start
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## Rendering Modes
|
|
203
|
+
|
|
204
|
+
| Mode | Description | Use Case |
|
|
205
|
+
|------|-------------|---------|
|
|
206
|
+
| **SSR** | Render on every request | Dynamic content, user-specific pages |
|
|
207
|
+
| **SSG** | Pre-render at build time | Static content, documentation |
|
|
208
|
+
| **ISR** | Re-render on interval (e.g., every 60s) | Blog posts, product pages |
|
|
209
|
+
| **Streaming SSR** | Stream HTML as it renders | Large pages, slow data sources |
|
|
210
|
+
| **Partial Prerender** | Static shell + dynamic holes | Mixed content (Next.js 14+) |
|
|
211
|
+
|
|
212
|
+
## Common Pitfalls
|
|
213
|
+
|
|
214
|
+
| Issue | Fix |
|
|
215
|
+
|-------|-----|
|
|
216
|
+
| Static resource 404 | Next.js: check `assetPrefix`; Nuxt: check `app.baseURL` |
|
|
217
|
+
| API Routes not working | Ensure Node.js >= 20.9; check runtime config for serverless |
|
|
218
|
+
| Env var leakage | Server vars should NOT have `NEXT_PUBLIC_` prefix (Next.js) |
|
|
219
|
+
| Memory leak in long-running | PM2: set `--max-memory-restart 500M`; check for event listener leaks |
|
|
220
|
+
| SSR hydration mismatch | Ensure server and client render identical HTML; avoid `Date.now()` in SSR |
|
|
221
|
+
| `getServerSideProps` slow | Add caching headers; use ISR; optimize database queries |
|
|
222
|
+
| Build fails with "out of memory" | Increase Node.js heap: `NODE_OPTIONS=--max-old-space-size=4096` |
|
|
223
|
+
| CSS flash on load (FOUC) | Extract CSS to files (default in most frameworks); avoid inline styles |
|
|
224
|
+
| Images not optimized | Next.js: use `<Image>` component; Nuxt: use `<NuxtImg>` |
|
|
225
|
+
| Next.js 16: Turbopack breaks build | Custom webpack config fails with Turbopack default; use `next build --webpack` |
|
|
226
|
+
| Next.js 16: params not awaited | `params`/`searchParams`/`cookies()`/`headers()` must be `await`ed |
|
|
227
|
+
| Next.js 16: middleware not found | Renamed to `proxy.ts`; export `proxy` function instead of `middleware` |
|
|
228
|
+
| Next.js 16: parallel route error | All parallel route slots now require explicit `default.js` files |
|