Browser Environment Variables in root CatchBoundary #5104
jamesarosen
started this conversation in
Show and tell / tips
Replies: 1 comment 1 reply
-
Because CatchBoundary is only rendered when you throw a response, you could add any env variable you may need to that thrown response the same way you add them to the returned responses. That should allow you to pass env variables to the root CatchBoundary even if they the root loader is the one that thrown a response. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
The documented approach to browser environment variables is to (A) send them to the browser with a
loader
, then set them onwindow.ENV
.useLoaderData
doesn't return anything in aCatchBoundary
, so this won't work:Assuming that it wasn't the root loader that threw the error, you can get its data via
useMatches
using the How to access Remix data in other routes pattern:I think it's nice to wrap all of that up into a single component and use that everywhere you need it:
I think this would make a great addition to the envvars guide.
Beta Was this translation helpful? Give feedback.
All reactions