All examples use mainnet and the Auth0 (JavaScript) provider. Mainnet requires approved credentials — apply for access to get your Auth0 client id. See Choose your SDK if you’re not sure which library fits your app.
How login works
NEAR Auth authenticates users through Auth0. Under the hood, theJavascriptProvider wraps Auth0’s SPA client and handles the OAuth handshake for you.
1
You call login()
The SDK opens Auth0 in a popup (the default) or via a full-page redirect, where the user signs in with Google, Apple, email, or a passkey.
2
Auth0 returns an identity
On success, Auth0 issues a JWT and the provider derives a stable user identity (the token’s
sub claim). With redirect login, the SDK completes the handshake automatically when the user lands back on your app.3
The session is stored
Auth0 persists the session in the browser, so a returning user stays logged in across reloads until they log out or the session expires.
Set up and authenticate
- React SDK
- Browser SDK
Install the React SDK and the JavaScript provider, then wrap your app in
FastAuthProvider.Wrap your app in the provider
Create aJavascriptProvider, open a NEAR Connection, and pass both to FastAuthProvider. The provider builds a FastAuthClient for you and makes it available through hooks anywhere in the tree.App.tsx
network="mainnet" tells the client which deployed contracts to use — it resolves fast-auth.near and the mainnet MPC signer for you, so you don’t pass contract ids in React.Log in and read session state
Two hooks cover the whole lifecycle:useFastAuth()→{ client, isReady }— the underlyingFastAuthClientand whether it has finished initializing.useIsLoggedIn()→{ isLoggedIn, isLoading, error, refetch }— the current session status. It checks automatically on mount (including finishing any redirect handshake), so a returning user is recognized without extra code.
LoginButton.tsx
Log out
Logging out clears the Auth0 session. After this the user is unauthenticated and you can no longer get a signer until they log in again.Next steps
Sign transactions
Turn an authenticated user into a signer and submit NEAR transactions.
Choose your SDK
Compare the React and Browser SDKs and pick the right fit.
React SDK reference
Providers, hooks, and the relayer-aware client.
Browser SDK reference
The
FastAuthClient and FastAuthSigner classes.