Hooks

useOkto

Learn how to use the useOkto hook to access Okto functionality in React Native components

The useOkto hook is the primary way to access Okto functionality within React Native components. It provides access to the Okto client instance, allowing you to manage authentication, user operations, and session management.

Hook Overview

HookDescription
useOktoAccess the Okto client instance and its methods

useOkto Hook

useOkto() returns an instance of OktoClient.

Requirements

This hook must be used within components wrapped by the OktoProvider.

OktoClient Properties and Methods

OktoClient Interface

PropertyTypeDescription
userUser | undefinedCurrent authenticated user information
userSWAHex | undefinedUser's Smart Wallet Address
clientSWAHex | undefinedClient's Smart Wallet Address
MethodSignatureDescription
loginUsingOAuthPromise<User>Authenticate using OAuth providers
verifyLoginPromise<boolean>Verify if user is logged in
getAuthorizationTokenPromise<string>Get current authorization token
paymasterDataPromise<Hex>Get paymaster data for transactions
executeUserOpPromise<string>Execute a user operation
signUserOpPromise<UserOp>Sign a user operation

On this page