import { AppState, Auth0Provider, User } from "@auth0/auth0-react";
const Auth0ProviderWithNavigate = ({
children,
}: {
children: React.ReactNode;
}) => {
const domain = import.meta.env.VITE_AUTH0_DOMAIN;
const clientId = import.meta.env.VITE_AUTH0_CLIENT_ID;
const redirectURI = import.meta.env.VITE_AUTH0_CALLBACK_URI;
if (!domain || !clientId || !redirectURI) {
throw new Error("Unable to initialise Auth");
}
const onRedirectCallback = (appState?: AppState, user?: User) => {
console.log("User: ", user);
console.log("AppState: ", appState);
};
return (
<Auth0Provider
domain={domain}
clientId={clientId}
authorizationParams={{ redirectURI: window.location.origin }}
onRedirectCallback={onRedirectCallback}
>
{children}
</Auth0Provider>
);
};
export default Auth0ProviderWithNavigate;
This is the Function where i have defined auth0. All the Env variable are correct and triple checked. I am using “@auth0/auth0-react”: “^2.2.4”, Can Anyone help regarding that.
I have tried different solutions published in the stackoverflow and the official website of Auth0 i.e Auth0.com But haven’t found any solution that worked for me.
New contributor
Athrav Mehta is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.