#Why do docs store env variables on window when you can get from root loader using useMatches?
1 messages · Page 1 of 1 (latest)
So you don’t need to pass them around
I personally prefer to be explicit so pass them as arguments
But wouldn't useMatches on root allow you to pull them server side in the component vs needing to wait on the window to be available after render?
Another thing you can do is to set them on window.process.env which will make process.env a thing client side, useful when using libraries that read from process.env directly because on webpack you can use the DefinePlugin to set them
Ah
The example on the docs shows how you could create a client only function, eg to initialize Stripe, and use window.ENV