See the full documentation in the React SDK. This hook is available identically in @chipi-stack/chipi-react, @chipi-stack/nextjs, and @chipi-stack/chipi-expo.
Session keys only work with CHIPI wallets.
import { useChipiSession } from "@chipi-stack/chipi-react";
// or: import { useChipiSession } from "@chipi-stack/nextjs";
// or: import { useChipiSession } from "@chipi-stack/chipi-expo";
const {
session,
sessionState,
hasActiveSession,
remainingCalls,
createSession,
registerSession,
executeWithSession,
revokeSession,
isCreating,
isRegistering,
isExecuting,
} = useChipiSession({
wallet,
encryptKey: pin,
getBearerToken: getToken,
storedSession,
onSessionCreated: (session) => {
localStorage.setItem("chipi-session", JSON.stringify(session));
},
});