Skip to content

Commit

Permalink
docs(recipe: expose isServer value to reuse across app (t3-oss#258)
Browse files Browse the repository at this point in the history
  • Loading branch information
Guria committed Aug 13, 2024
1 parent b55ca31 commit 5c63e40
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions docs/src/app/docs/recipes/page.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,22 @@ const config: StorybookConfig = {

export default config;
```

## isServer

The `shared` section can be used to define environment variables that are accessible
in both client and server contexts. This is particularly useful for distinguishing
between server and client environments without repeating checks throughout your application.

```ts
export const env = createEnv({
shared: {
IS_SERVER: z.boolean().default(false),
},
runtimeEnv: {
IS_SERVER: typeof window === "undefined",
}
})
```

See also way to [customize `isServer` value used by the library itself](../customization#tell-when-we're-in-a-server-context)

0 comments on commit 5c63e40

Please sign in to comment.