Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose internal value for isServer #258

Open
Guria opened this issue Aug 13, 2024 · 0 comments · May be fixed by #259
Open

Expose internal value for isServer #258

Guria opened this issue Aug 13, 2024 · 0 comments · May be fixed by #259

Comments

@Guria
Copy link

Guria commented Aug 13, 2024

It might be useful across the app to reuse alreday calculated value:

import { env } from "~/env"

  if (env.isServer) {
    // Server: always make a new query client
    return createQueryClient();
  }
  // Browser: use singleton pattern to keep the same query client
  return (clientQueryClientSingleton ??= createQueryClient());
Guria added a commit to Guria/t3-env that referenced this issue Aug 13, 2024
Fixes t3-oss#258

Expose the internal value for `isServer` for reuse across the app.

* **packages/core/src/index.ts**
  - Add `isServer` property to the `CreateEnv` return type.
  - Update the `createEnv` function to include `isServer` in the proxy handler.
* **examples/astro/src/t3-env.ts**
  - Import `isServer` value from the `env` object.
* **examples/nextjs/app/env.ts**
  - Import `isServer` value from the `env` object.
* **examples/nuxt/env.ts**
  - Import `isServer` value from the `env` object.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/t3-oss/t3-env/issues/258?shareId=XXXX-XXXX-XXXX-XXXX).
@Guria Guria linked a pull request Aug 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant