Skip to content

Commit d9a9179

Browse files
committed
feat: ✨ use connection api for opting in to dynamic rendering
BREAKING CHANGE: The `unstable_noStore` API has been removed from Next.js, use the `connection` API to opt in to dynamic rendering.
1 parent 20f5609 commit d9a9179

File tree

21 files changed

+4891
-3919
lines changed

21 files changed

+4891
-3919
lines changed

.github/actions/back-merge/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,5 @@ runs:
3838
git fetch --unshallow
3939
git checkout development
4040
git pull
41-
git merge --no-ff origin/${{ inputs.main_branch }} -m "🔀 Back-merge ${{ inputs.main_branch }} into development"
41+
git merge --no-ff origin/${{ inputs.main_branch }} -m "ci: 🔀 back-merge ${{ inputs.main_branch }} into development"
4242
git push

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020

2121
strategy:
2222
matrix:
23-
node-version: [18, 20]
23+
node-version: [20, 22]
2424

2525
steps:
2626
- name: Checkout
@@ -42,7 +42,7 @@ jobs:
4242

4343
strategy:
4444
matrix:
45-
node-version: [18, 20]
45+
node-version: [20, 22]
4646

4747
steps:
4848
- name: Checkout
@@ -64,7 +64,7 @@ jobs:
6464

6565
strategy:
6666
matrix:
67-
node-version: [18, 20]
67+
node-version: [20, 22]
6868

6969
steps:
7070
- name: Checkout

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717

1818
strategy:
1919
matrix:
20-
node-version: [20]
20+
node-version: [22]
2121

2222
steps:
2323
- name: Checkout

.npmignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
.env.sample
77
.eslintignore
88
.eslintrc.js
9-
.releaserc.yaml
9+
.releaserc.json
1010
codecov.yml
1111
jest.config.js
1212
prettier.config.js

.releaserc.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"branches": [
3+
{
4+
"name": "1.x",
5+
"range": "1.x",
6+
"channel": "1.x"
7+
},
8+
{
9+
"name": "2.x",
10+
"range": "2.x",
11+
"channel": "2.x"
12+
},
13+
{
14+
"name": "main"
15+
},
16+
{
17+
"name": "development",
18+
"prerelease": "alpha",
19+
"channel": "alpha"
20+
}
21+
],
22+
"plugins": [
23+
[
24+
"@semantic-release/commit-analyzer",
25+
{
26+
"parserOpts": {
27+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
28+
},
29+
"preset": "angular",
30+
"releaseRules": [
31+
{ "type": "build", "release": "patch" },
32+
{ "type": "refactor", "release": "patch" },
33+
{ "type": "style", "release": "patch" }
34+
]
35+
}
36+
],
37+
[
38+
"@semantic-release/release-notes-generator",
39+
{
40+
"parserOpts": {
41+
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES", "BREAKING"]
42+
},
43+
"preset": "conventionalcommits",
44+
"presetConfig": {
45+
"types": [
46+
{ "type": "build", "section": "Build System", "hidden": false },
47+
{
48+
"type": "ci",
49+
"section": "Continuous Integration",
50+
"hidden": false
51+
},
52+
{ "type": "docs", "section": "Documentation", "hidden": false },
53+
{ "type": "feat", "section": "Features", "hidden": false },
54+
{ "type": "fix", "section": "Bug Fixes", "hidden": false },
55+
{
56+
"type": "perf",
57+
"section": "Performance Improvements",
58+
"hidden": false
59+
},
60+
{
61+
"type": "refactor",
62+
"section": "Code Refactoring",
63+
"hidden": false
64+
},
65+
{ "type": "style", "section": "Styles", "hidden": false },
66+
{ "type": "test", "section": "Tests", "hidden": false }
67+
]
68+
},
69+
"writerOpts": {
70+
"commitsSort": ["subject", "scope"]
71+
}
72+
}
73+
],
74+
"@semantic-release/npm",
75+
"@semantic-release/github"
76+
]
77+
}

.releaserc.yaml

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
🌟 **Highlights:**
88
- **Isomorphic Design:** Works seamlessly on both server and browser, and even in middleware.
9-
- **Next.js 13 & 14 Ready:** Fully compatible with the latest Next.js features.
9+
- **Next.js 13, 14, and 15 Ready:** Fully compatible with the latest Next.js features.
1010
- **`.env` Friendly:** Use `.env` files during development, just like standard Next.js.
1111

1212
### 🤔 Why `next-runtime-env`?
@@ -19,6 +19,7 @@ In the modern software development landscape, the "[Build once, deploy many][bui
1919

2020
### 🤝 Compatibility Notes
2121

22+
- **Next.js 15:** Use `next-runtime-env@4.x` for new connection API.
2223
- **Next.js 14:** Use `next-runtime-env@3.x` for optimal caching support.
2324
- **Next.js 13:** Opt for [`next-runtime-env@2.x`][app-router-branch-link], tailored for the App Router.
2425
- **Next.js 12/13 Page Router:** Stick with [`next-runtime-env@1.x`][pages-router-branch-link].
@@ -28,6 +29,7 @@ In the modern software development landscape, the "[Build once, deploy many][bui
2829
- **1.x:** Next.js 12/13 Page Router
2930
- **2.x:** Next.js 13 App Router
3031
- **3.x:** Next.js 14 with advanced caching
32+
- **3.x:** Next.js 15 with new connection API
3133

3234
### 🚀 Getting Started
3335

docs/EXPOSING_CUSTOM_ENV.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ You might not only want to expose environment variables that are prefixed with `
1515
```tsx
1616
// app/layout.tsx
1717
// This is as of Next.js 14, but you could also use other dynamic functions
18-
import { unstable_noStore as noStore } from 'next/cache';
18+
import { connection } from 'next/server'
1919
import { EnvScript } from 'next-runtime-env';
2020

21-
export default function RootLayout({
21+
export default async function RootLayout({
2222
children,
2323
}: {
2424
children: React.ReactNode;
2525
}) {
26-
noStore(); // Opt into dynamic rendering
26+
await connection(); // Opt into dynamic rendering
2727

2828
// This value will be evaluated at runtime
2929
return (
@@ -55,15 +55,15 @@ You might not only want to expose environment variables that are prefixed with `
5555
```tsx
5656
// app/layout.tsx
5757
// This is as of Next.js 14, but you could also use other dynamic functions
58-
import { unstable_noStore as noStore } from 'next/cache';
58+
import { connection } from 'next/server'
5959
import { EnvProvider } from 'next-runtime-env';
6060

61-
export default function RootLayout({
61+
export default async function RootLayout({
6262
children,
6363
}: {
6464
children: React.ReactNode;
6565
}) {
66-
noStore(); // Opt into dynamic rendering
66+
await connection(); // Opt into dynamic rendering
6767

6868
// This value will be evaluated at runtime
6969
return (
Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
experimental: {
4-
serverComponentsExternalPackages: ['next-runtime-env'],
5-
// This is optional incase you want to make some private env vars publicly
6-
// available.
7-
instrumentationHook: true,
8-
},
3+
serverExternalPackages: ['next-runtime-env'],
94
};
105

116
module.exports = nextConfig;

examples/with-app-router-context/package.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@
99
"lint": "next lint"
1010
},
1111
"dependencies": {
12-
"@types/node": "20.12.12",
13-
"@types/react": "18.3.2",
14-
"@types/react-dom": "18.3.0",
15-
"eslint": "8.57.0",
16-
"eslint-config-next": "14.2.3",
17-
"next": "14.2.3",
12+
"@types/node": "22.10.6",
13+
"@types/react": "19.0.7",
14+
"@types/react-dom": "19.0.3",
15+
"eslint": "9.18.0",
16+
"eslint-config-next": "15.1.4",
17+
"next": "15.1.4",
1818
"next-runtime-env": "link:../..",
19-
"react": "18.3.1",
20-
"react-dom": "18.3.1",
21-
"typescript": "5.4.5"
19+
"react": "19.0.0",
20+
"react-dom": "19.0.0",
21+
"typescript": "5.7.3"
2222
}
2323
}

0 commit comments

Comments
 (0)