diff --git a/docs/src/app/docs/recipes/page.mdx b/docs/src/app/docs/recipes/page.mdx index 1e23f95d..9ca23a1a 100644 --- a/docs/src/app/docs/recipes/page.mdx +++ b/docs/src/app/docs/recipes/page.mdx @@ -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)