You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-6
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,17 @@ your environment variables at build time. The context provider safely exposes al
31
31
32
32
### Compatibility 🤝
33
33
34
-
Because `next-runtime-env` is build on top of server components it is only compatible with Next.js 13 App Router. Use [version 1.x][pages-router-branch-link] for Next.js 13 Page Router support.
34
+
Because `next-runtime-env` uses Next.js 14 caching, it is only compatible with Next.js 14 and up.
35
+
36
+
To use with Next.js 13 use [version 2.x][pages-router-branch-link]. Version 2.x is build on top of server components it is only compatible with Next.js 13 App Router.
37
+
38
+
Use [version 1.x][pages-router-branch-link] for Next.js 12/13 Page Router support.
@@ -54,11 +64,6 @@ export default function RootLayout({
54
64
</html>
55
65
);
56
66
}
57
-
58
-
// By default server components are statically generated at build-time. To make
59
-
// sure the env vars are actually loaded use, add the following line to server
60
-
// components that use [env]. 👇
61
-
exportconstdynamic='force-dynamic';
62
67
```
63
68
64
69
The `PublicEnvProvider` will automatically expose all environment variables prefixed with `NEXT_PUBLIC_` to the context. If you want more control over which variables are exposed to the context, you can use the `EnvProvider` and define the exposed variables manually.
@@ -94,8 +99,13 @@ export default function SomePage() {
94
99
95
100
```tsx
96
101
// app/server-page.tsx
102
+
// This is as of Next.js 14, but you could also use other dynamic functions
Copy file name to clipboardExpand all lines: docs/GETTING_STARTED.md
+1-13
Original file line number
Diff line number
Diff line change
@@ -33,19 +33,7 @@ export default function RootLayout({
33
33
34
34
> Keep in mind that the RuntimeEnvProvider must be added in a Server Component.
35
35
36
-
3. Next force dynamic generation for the Server Component by adding the following line:
37
-
38
-
```tsx
39
-
// src/app/layout.tsx
40
-
41
-
// ...
42
-
43
-
exportconst dynamic ='force-dynamic';
44
-
```
45
-
46
-
> By default server components are statically generated at build-time. To make sure the env vars are actually loaded during runtime, you need to force dynamic generation.
47
-
48
-
4. Finally, use `useEnvContext` hook to access the runtime environment variables in your components:
36
+
3. Finally, use `useEnvContext` hook to access the runtime environment variables in your components:
0 commit comments