@fast-auth-near/react-native-provider package ships ReactNativeProvider, the mobile identity provider for NEAR Auth. It adapts react-native-auth0 to the shared provider interface so your iOS and Android app can authenticate users with Auth0 and request NEAR signatures using the platform’s native Web Authentication browser.
Like every provider, it implements IFastAuthProvider and is designed to be injected into a FastAuthClient from the React SDK. The provider handles Auth0 login and signature requests; the SDK handles NEAR account and transaction plumbing.
This is the mobile counterpart of the JavaScript provider. It exposes the same method surface but authenticates through the native Auth0 SDK instead of a web popup or redirect. See Key differences below.
Installation
react-native-auth0, near-api-js, @near-js/transactions, and jose. It requires react (>=16.8.0) and react-native (>=0.60.0) as peer dependencies.
Constructor
ReactNativeProvider takes a single options object. Only network and clientId are required — domain and signingAudience fall back to the NEAR Auth defaults for the chosen network.
The NEAR network to target. Selects the default Auth0
domain and signingAudience for that network.Your Auth0 application client ID.
The Auth0 domain. Defaults to
login.auth.near.org on mainnet and login.testnet.fast-auth.com on testnet.The Auth0 API audience used when requesting signature tokens. Defaults to
auth0.jwt.fast-auth.near on mainnet and auth0.jwt.fast-auth.testnet on testnet.FAST_AUTH_AUTH0_DEFAULTS[network] and instantiates the underlying Auth0 client with the resolved domain and clientId.
Network defaults
| Network | domain | signingAudience |
|---|---|---|
mainnet | login.auth.near.org | auth0.jwt.fast-auth.near |
testnet | login.testnet.fast-auth.com | auth0.jwt.fast-auth.testnet |
Setup with <Auth0Provider>
react-native-auth0 requires an Auth0Provider context around your component tree. The package re-exports Auth0Provider for convenience, so you can wrap your app and construct the ReactNativeProvider in one place.
App.tsx
domain and clientId you pass to <Auth0Provider> must match the ones the ReactNativeProvider resolves, so both talk to the same Auth0 tenant.
Using it with the React SDK
To drive the provider through the React SDK hooks, use thereactNativeProviderConfig helper. It returns both the provider instance and a reactProvider render function that wraps children in the correct <Auth0Provider> for you — pass the whole config straight to FastAuthProvider.
App.tsx
reactNativeProviderConfig accepts the same options as the constructor and returns { provider, reactProvider }. From there, use useFastAuth, useIsLoggedIn, and useSigner exactly as documented in the React SDK reference.
Methods
ReactNativeProvider exposes the full IFastAuthProvider surface. Every method is asynchronous.
| Method | Purpose |
|---|---|
login(forceSelectAccount?) | Sign in via native Web Authentication and persist the session. |
logout() | Clear the remote Auth0 session and local credentials. |
isLoggedIn() | Check whether valid, unexpired session credentials exist. |
getPath() | Return the NEAR Auth path derived from the session subject. |
requestTransactionSignature({ transaction }) | Open an authorization flow to approve signing a transaction. |
requestDelegateActionSignature({ delegateAction }) | Open an authorization flow to approve signing a delegate action. |
getSignatureRequest() | Consume the one-shot signing credentials into a SignatureRequest. |
login
sub) from the returned credentials and persists the session through the Auth0 credentialsManager, so the user stays signed in across app launches. Resolves to a LoginResponse ({ userId }).
Pass forceSelectAccount: true to send Auth0 prompt=login, forcing the account picker instead of silently reusing an existing session.
logout
isLoggedIn
true only when the credentialsManager holds credentials whose expiresAt is still in the future. Any error while reading credentials resolves to false, so this is safe to call on startup.
getPath
ReactNativeProviderError with code CREDENTIALS_NOT_FOUND when there is no session ID token.
requestTransactionSignature
Transaction, then opens a fresh Web Authentication flow against the signingAudience with scope transaction:sign, embedding the encoded transaction as an authorization parameter. The resulting signing token is held in memory only — it does not touch the persisted session — and is decoded by getSignatureRequest. Resolves to the authenticated { userId }.
Options are passed directly — there is no wrapping
options key. Pass { transaction }, not { options: { transaction } }.requestDelegateActionSignature
requestTransactionSignature but for a DelegateAction (the meta-transaction submitted through a relayer for gasless signing). It encodes the delegate action, opens the signing flow against the signingAudience with scope transaction:sign, and keeps the signing token in memory for getSignatureRequest to consume.
getSignatureRequest
requestTransactionSignature or requestDelegateActionSignature call and returns the SignatureRequest your app submits on-chain:
user ({ userId }) from the token’s subject.
Key differences vs the JavaScript provider
Both providers implementIFastAuthProvider and expose the same methods, so you can swap platforms with minimal code changes. The behavioral differences come from mobile Auth0:
Native Web Authentication
Login always uses the system browser via
react-native-auth0. There is no popup-vs-redirect choice like on web — the JavaScript provider exposes both.Persistent sessions
Session credentials are stored by the Auth0
credentialsManager, so users stay signed in across app restarts without re-authenticating.In-memory, one-shot signing
Signing tokens are kept in memory and consumed once by
getSignatureRequest. They never touch the persisted session, and a second read throws.Params without an options wrapper
Signature methods take
{ transaction } / { delegateAction } directly. There is no redirectUri option, since mobile does not redirect the way the web provider can.Error handling
Provider failures throw aReactNativeProviderError carrying a typed code. Import both to branch on the failure reason:
| Code | Meaning |
|---|---|
USER_NOT_LOGGED_IN | An operation needed an authenticated user but none was present. |
CREDENTIALS_NOT_FOUND | No session or signing credentials were found in storage or memory. |
INVALID_SUB | The token did not contain a valid sub (subject) claim. |
INVALID_TOKEN | The token was malformed or could not be decoded. |
Full example
App.tsx
Next steps
React SDK
Inject this provider into
FastAuthClient and drive it with hooks.JavaScript provider
The web counterpart with popup and redirect login.
Authenticate users
Login, logout, and session handling end to end.
Sign transactions
Turn a signature request into a submitted NEAR transaction.
Choose your SDK
See how the providers and SDKs fit different stacks.
All SDKs
Browse every published NEAR Auth library.