@ankr.com/auth
v2.0.1
Published
### Usage
Downloads
35
Readme
Helper for https://auth.ankr.com/ integration
Usage
import { AuthContextProvider, useAuth } from '@ankr.com/auth';
export const API_BASE_URL = IS_PROD
? 'https://prod.url'
: 'https://stage-dev.url';
export const Gateways: ReturnType<typeof createGateways> = createGateways({
baseURL: API_BASE_URL,
});
export const authParams = {
authPath: IS_PROD ? 'https://auth.ankr.com/?providers=google' : 'https://stage-auth.ankr.com/?providers=google',
appPath: IS_PROD ? 'app.ankr.com' : 'stage.app.ankr.com',
};
export function Component({ children }: IAppBaseProps): JSX.Element {
const { isSignedIn, handleSignOut, handleSignIn } = useAuth(authParams);
console.log('isSignedIn', isSignedIn);
if (isSignedIn === undefined) {
return <QueryLoadingAbsolute />;
}
return <>
<Button onClick={handleSignIn}>handleSignIn</Button>
<Button onClick={handleSignOut}>handleSignOut</Button>
</>;
}
function App(): JSX.Element {
return (
<AuthContextProvider Gateways={Gateways}>
<Component/>
</AuthContextProvider>
);
}