In writing a create-react-app application with authentication provided by Auth0, using a .env file, I am getting a "domain option is required" error. What's causing it and how do I fix it?
(As seen in the code import statements, I'm using the react-use-auth npm module.)
Note: This answer to this question may be found in other SO questions, but they don't reference this error. Hopefully this question helps people with this error find the solution faster. I'm posting the solution I found, but if this error has other causes it'd be great to document those, too.
index.js file:
import React from 'react';
import ReactDOM from 'react-dom';
import { withRouter } from "react-router-dom";
import { AuthProvider } from "react-use-auth";
import App from './App';
ReactDOM.render(
<React.StrictMode>
<AuthProvider
navigate={props.history.push}
auth0_domain={process.env.REACT_APP_AUTH0_DOMAIN}
auth0_client_id={process.env.REACT_APP_AUTH0_CLIENT_ID}>
<App />
</AuthProvider>
</React.StrictMode>,
document.getElementById('root')
);
export default withRouter(App);
.env file (in root directory created by create-react-app):
REACT_APP_AUTH0_DOMAIN=[auth0_domain_name]
REACT_APP_AUTH0_CLIENT_ID=[auth0_client_id]