
AI Assisted
この記事は筆者の実装経験をもとに実装コードをベースで執筆し、AIによる校閲・推敲を経て公開しています。
実際に当サイト(nero15.dev)を Next.js 15.1.0 から 16.1.0 にアップグレードしました。 React 19 へのメジャーアップデートも含まれており、いくつかの破壊的変更に対応する必要がありましたが、作業自体は約30分で完了しました。
実際に行った作業手順と、予期せぬエラー(500エラーなど)の解決策をまとめます。
| 項目 | Before | After |
|---|---|---|
| Next.js | 15.1.0 | 16.1.0 |
| React | 18.3.1 | 19.2.0 |
| Node.js | >=18.0.0 | >=20.9.0 |
修正スコープ: 設定ファイル中心に約6ファイル
まずは依存関係を最新にします。React 19系への更新が含まれます。
"dependencies": {
- "next": "^15.1.0",
- "react": "^18.3.1",
- "react-dom": "^18.3.1"
+ "next": "^16.1.0",
+ "react": "^19.2.0",
+ "react-dom": "^19.2.0"
},
"devDependencies": {
- "@types/react": "^18.3.17",
- "@types/react-dom": "^18.3.5",
- "eslint-config-next": "^15.1.0"
+ "@types/react": "^19.1.0",
+ "@types/react-dom": "^19.1.0",
+ "eslint-config-next": "^16.1.0"
},
"engines": {
- "node": ">=18.0.0"
+ "node": ">=20.9.0"
}
npm install next@latest react@latest react-dom@latest
npm install -D @types/react@latest @types/react-dom@latest eslint-config-next@latest
Next.js 16からTurbopackがさらに強化されました。設定オブジェクトを追加しておきます。
// next.config.js
const nextConfig = {
// Turbopack configuration
turbopack: {},
// ...
}
images.domains が非推奨となったため、よりセキュアな remotePatterns に書き換えます。プロトコルの指定が必須になる点に注意です。
// Before (非推奨)
images: {
domains: ['firebasestorage.googleapis.com', 'nero15.dev', 'localhost'],
}
// After
images: {
remotePatterns: [
{
protocol: 'https',
hostname: 'firebasestorage.googleapis.com',
},
{
protocol: 'https',
hostname: 'nero15.dev',
},
{
protocol: 'http',
hostname: 'localhost',
},
],
}
React 19 では新しいJSXトランスフォームが推奨されるため、jsx 設定を変更します。これにより若干のパフォーマンス向上が期待できます。
// tsconfig.json
{
"compilerOptions": {
- "jsx": "preserve"
+ "jsx": "react-jsx"
}
}
ここからは、アップグレード後に発生したエラーとその対処法です。
React 19の型定義変更により、useRef の初期値が必須になりました。これを修正しないと大量の型エラーが発生します。
症状: Type 'undefined' is not assignable to type 'number'
// Before
const animationRef = useRef<number>()
// After: 初期値 undefined を明示し、型も許容する
const animationRef = useRef<number | undefined>(undefined)
Server Component から Client Component へ関数(イベントハンドラ)を渡すことができなくなりました。
症状:
Error: Event handlers cannot be passed to Client Component props.
<button onClick={function handleClick}>
If you need interactivity, consider converting part of this to a Client Component.
対処法:
これが一番のハマりどころでした。Next.js 16で Metadata の型定義が厳格化され、openGraph.tags プロパティを使うと実行時エラー(500 Internal Server Error)になるケースがあります。
対処法: openGraph.tags は使わず、汎用的な other フィールドを使用します。
// Before: 500エラーの原因
openGraph: {
tags: ['tag1', 'tag2'],
}
// After
other: {
'article:tag': tags.join(','),
}
以下の変更については、現時点で動作に影響がないため、後日対応としました。
Next.js 16 は Turbopack による開発体験の向上が著しいので、早めの移行をおすすめします。
スポーツ×ITの会社でバックエンドエンジニア兼マネージャーとして勤務。インテル関連の情報を中心に、AI・IT技術やサイト運用ノウハウも発信しています。
最終更新: 2026年1月3日
© 2025 nero15.dev. All rights reserved.