@8base/react-auth 中文文档教程
8base Auth
8base React Auth 包包含一个提供身份验证状态和身份验证助手的提供程序。
AuthProvider
Table of Contents
AuthProvider
Extends React.Component
提供对身份验证状态的访问。
Parameters
props
AuthProviderProps
Properties
children
React$Node Children of the provider.authClient
AuthClient Instance of the auth client.
Usage
import { AuthContext, AuthProvider, type AuthContextProps } from '@8base/react-auth';
import { WebAuth0AuthClient } form '@8base/web-auth0-auth-client';
const authClient = new WebAuth0AuthClient({
domain: 'domain',
clientId: 'client-id',
redirectUri: `${window.location.origin}/auth/callback`,
logoutRedirectUri: `${window.location.origin}/auth`,
workspaceId: 'workspace-id',
});
<AuthProvider authClient={ authClient }>
...
<AuthContext.Consumer>
{
(auth: AuthContextProps) => (<div />)
}
</AuthContext.Consumer>
...
</AuthProvider>
8base Auth
The 8base React Auth package contains a provider with authentication state and auth helpers.
AuthProvider
Table of Contents
AuthProvider
Extends React.Component
Provides access to the authentication state.
Parameters
props
AuthProviderProps
Properties
children
React$Node Children of the provider.authClient
AuthClient Instance of the auth client.
Usage
import { AuthContext, AuthProvider, type AuthContextProps } from '@8base/react-auth';
import { WebAuth0AuthClient } form '@8base/web-auth0-auth-client';
const authClient = new WebAuth0AuthClient({
domain: 'domain',
clientId: 'client-id',
redirectUri: `${window.location.origin}/auth/callback`,
logoutRedirectUri: `${window.location.origin}/auth`,
workspaceId: 'workspace-id',
});
<AuthProvider authClient={ authClient }>
...
<AuthContext.Consumer>
{
(auth: AuthContextProps) => (<div />)
}
</AuthContext.Consumer>
...
</AuthProvider>