Hooks
useOkto
Learn how to use the useOkto hook to access Okto functionality in React components
The useOkto
hook is the primary way to access Okto functionality within React components. It provides access to the Okto client instance, allowing you to manage authentication, user operations, and session management.
Hook Overview
Hook | Description |
---|---|
useOkto | Access 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
Property | Type | Description |
---|---|---|
user | User | undefined | Current authenticated user information |
userSWA | Hex | undefined | User's Smart Wallet Address |
clientSWA | Hex | undefined | Client's Smart Wallet Address |
Method | Signature | Description |
---|---|---|
loginUsingOAuth | Promise<User> | Authenticate using OAuth providers |
verifyLogin | Promise<boolean> | Verify if user is logged in |
getAuthorizationToken | Promise<string> | Get current authorization token |
paymasterData | Promise<Hex> | Get paymaster data for transactions |
executeUserOp | Promise<string> | Execute a user operation |
signUserOp | Promise<UserOp> | Sign a user operation |