#How to access loader data in the ErrorBoundary?

1 messages · Page 1 of 1 (latest)

atomic elbow
#

Hello! Is there any way to access loader data, environment variables, or a request in the root ErrorBoundary? I would like to customise the 500 error screen depending on the environment

wicked girder
#

For environment variables, you could create a Document component that encapsulates the html, head, body, Scripts, etc., receives the env values from the root loader and sets them to window. Then use it to wrap the contents of your App and ErrorBoundary, so you'll have access to them in either scenario.

You can find an example in the epic-stack repo: https://github.com/epicweb-dev/epic-stack/blob/main/app/root.tsx#L192-L226