How to tell TypeScript about browser environment variables? #3004
Replies: 1 comment
-
// entry.server.tsx
export type EnvironmentVariables = {
MAGIC_PUBLISHABLE_KEY?: string
}
// entry.client.tsx
import type { EnvironmentVariables } from './entry.server'
declare global {
var ENV: EnvironmentVariables
}
console.log(window.ENV.MAGIC_PUBLISHABLE_KEY)
hydrate(<RemixBrowser />, document) |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
janhesters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm using TypeScript for my Remix app.
I'm following the tutorial on how to use browser environment variables.
When I now try to use those variables:
But TypeScript yells saying:
How can I tell TypeScript about
window.ENV
and that it hasEnvironmentVariables
as the types?Beta Was this translation helpful? Give feedback.
All reactions