I'm trying to get some environment variables into the browser with Remix and I've been following this:
https://remix.run/docs/en/v1/guides/envvars
I have followed steps 1 and 2 exactly, however I'm not able to access window.ENV
from the browser. I'm getting this error: ReferenceError: window is not defined
And here is my really simple component:
function Test() {
console.log('Window: ', window);
return <div>Hello, Test</div>;
}
export default Test;
If I comment out the console.log
I can see the <script>
in the <body>
towards the top of the document with the window.ENV = {...}
contents. However uncommenting console.log
shows me the error message and no <script>
tag. This tells me the issue is with setting window.ENV
from the documentation and not from my component.
Any thoughts would be appreciated!