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
{{ message }}
Repository navigation
Commit a9dbeb7
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: docs/start/framework/react/environment-functions.md
+13-13Lines changed: 13 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,11 +7,11 @@ title: Environment Functions
7
7
8
8
Environment functions are utilities designed to define and control function execution based on the runtime environment—whether the code is running on the client or the server. These utilities help ensure that environment-specific logic is executed safely and intentionally, preventing runtime errors and improving maintainability in fullstack or isomorphic applications.
9
9
10
-
Start provide three core environment functions:
10
+
Start provides three core environment functions:
11
11
12
12
-`createIsomorphicFn`: Compose a single function that adapts to both client and server environments.
13
-
-`serverOnly`: Ensures a function can only run on the server.
14
-
-`clientOnly`: Ensures a function can only run on the client.
13
+
-`createServerOnlyFn`: Create a function that can only run on the server.
14
+
-`createClientOnlyFn`: Create a function that can only run on the client.
15
15
16
16
---
17
17
@@ -87,28 +87,28 @@ function noop() {}
87
87
88
88
## `env`Only Functions
89
89
90
-
The `serverOnly` and `clientOnly` helpers enforce strict environment-bound execution. They ensure the decorated function is only callable in the correct runtime context. If misused, they throw descriptive runtime errors to prevent unintentional logic execution.
90
+
The `createServerOnlyFn` and `createClientOnlyFn` helpers enforce strict environment-bound execution. They ensure the returned function is only callable in the correct runtime context. If misused, they throw descriptive runtime errors to prevent unintentional logic execution.
// ❌ On server: throws "clientOnly() functions can only be called on the client!"
111
+
// ❌ On server: throws "createClientOnlyFn() functions can only be called on the client!"
112
112
```
113
113
114
114
> [!NOTE]
@@ -120,4 +120,4 @@ Environment functions are tree-shaken based on the environment for each bundle p
120
120
121
121
Functions created using `createIsomorphicFn()` are tree-shaken. All codes inside `.client()` are not included in server bundle, and vice-versa.
122
122
123
-
On the server, implementation of `clientOnly` functions are replaced with a function that throws an `Error`. The reverse is true for `serverOnly` functions on the client.
123
+
On the server, functions created using `createClientOnlyFn()`are replaced with a function that throws an `Error` on the server. The reverse is true for `createServerOnlyFn` functions on the client.
@@ -114,13 +118,15 @@ Deploy your application using their one-click deployment process, and you're rea
114
118
115
119
**⚠️ During TanStack Start 1.0 release candidate phase, we currently recommend using:**
116
120
117
-
-[@tanstack/tanstack-nitro-v2-vite-plugin (Temporary Compatibility Plugin)](https://www.npmjs.com/package/@tanstack/tanstack-nitro-v2-vite-plugin) - A temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start.
121
+
-[@tanstack/nitro-v2-vite-plugin (Temporary Compatibility Plugin)](https://www.npmjs.com/package/@tanstack/nitro-v2-vite-plugin) - A temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start.
118
122
-[Nitro v3's Vite Plugin (BETA)](https://www.npmjs.com/package/nitro-vite) - A **BETA** plugin for officially using Nitro v3 as the underlying build tool for TanStack Start.
119
123
120
124
#### Using Nitro v2
121
125
122
126
**⚠️ `@tanstack/nitro-v2-vite-plugin` is a temporary compatibility plugin for using Nitro v2 as the underlying build tool for TanStack Start. Use this plugin if you experience issues with the Nitro v3 plugin. It does not support all of Nitro v3's features and is limited in it's dev server capabilities, but should work as a safe fallback, even for production deployments for those who were using TanStack Start's alpha/beta versions.**
123
127
128
+
If you want to use this plugin with bun please make sure to use [isolated installs](https://bun.com/docs/install/isolated#using-isolated-installs).
**⚠️ The `nitro/vite` plugin is an official **BETA** plugin from the Nitro team for using Nitro v3 as the underlying build tool for TanStack Start. It is still in development and is receiving regular updates.**
149
+
**⚠️ The `nitro` vite plugin is an official **BETA** plugin from the Nitro team for using Nitro v3 as the underlying build tool for TanStack Start. It is still in development and is receiving regular updates.**
0 commit comments