#Browser Environment Variables For 404s

1 messages · Page 1 of 1 (latest)

harsh quarry
#

The documentation on browser environment variables suggests returning them from the root loader . https://remix.run/docs/en/main/guides/envvars#browser-environment-variables

This works great for the happy path and even the unhappy path, so long as the error occurs outside of the root loader. However, if no route is matched, Remix will not run the root loader and your root error boundary won't have any access to these environment variables. Is there a way to expose client environment variables to the root Error Boundary for a route 404?

calm hedge
#

If your root error boundary is throwing, then you've got some problems. You're better off making sure that each of your layout and children routes have their own error boundaries, to make sure the root loader is still able to execute.

harsh quarry
#

The boundary isn't throwing. If I don't have a /foo route in my app, Remix will render the root error boundary

#

But because there are no matches, there is no root loader data

calm hedge
#

Add a routes/$.tsx route to handle 404s/no matches.

harsh quarry
#

I'll give that a go

#

thanks

harsh quarry
#

Feels odd to have to have a loader that always returns a 404 for the catchall route