Skip to main content
SessionWalletProvider is a higher-order component that wraps around your app components to provide the sessionWallet context throughout the application. Here’s an example of how to use the SessionWalletProvider:
  1. Create a new file named components/SessionProvider.tsx
  1. In your _app.tsx file, wrap the SessionProvider around the entire app to ensure it’s accessible within every component:
Note: Ensure that all your Solana wallet adapter contexts are the parent of the SessionProvider.
  1. With the SessionWalletProvider set up, you can now use the useSessionWallet hook in your components:

Using useSessionWallet in components

useSessionWallet is a custom hook that provides access to the session wallet context value. Use this hook in any component wrapped by the SessionWalletProvider. To properly understand what the useSessionWallet hook provides, we need to examine the SessionWalletInterface. This is what useSessionKeyManager returns, providing the methods needed to utilize session keys as well as transaction signing and sending capabilities.
This will help us understand how to use the sessionWallet in our code for creating session tokens as well as revoking them when no longer needed.