Manage user sessions

By default, AlchemyWebSigner user sessions are cached in localStorage for 15 minutes.

You can customize session length by passing a sessionConfig to your AlchemyWebSigner constructor.

You can check if the user has an active session with the following command:

import { 
import signer
signer
} from "./signer";
// NOTE: this method throws if there is no authenticated user // so we return null in the case of an error const
const user: any
user
= await
import signer
signer
.
any
getAuthDetails
().
any
catch
(() => null);
import { 
class AlchemyWebSigner

A SmartAccountSigner that can be used with any SmartContractAccount

AlchemyWebSigner
} from "@account-kit/signer";
export const
const signer: AlchemyWebSigner
signer
= new
new AlchemyWebSigner(params: AlchemySignerParams): AlchemyWebSigner

Initializes an instance with the provided Alchemy signer parameters after parsing them with a schema.

AlchemyWebSigner
({
client: ({ connection: { apiKey: string; rpcUrl?: undefined; jwt?: undefined; } | { jwt: string; rpcUrl?: undefined; apiKey?: undefined; } | { rpcUrl: string; apiKey?: undefined; jwt?: undefined; } | { rpcUrl: string; jwt: string; apiKey?: undefined; }; ... 4 more ...; enablePopupOauth?: boolean | undefined; } | AlchemySignerWebClient) & (AlchemySignerWebClient | ... 1 more ... | undefined)
client
: {
connection: { apiKey: string; }
connection
: {
apiKey: string
apiKey
: "API_KEY",
},
iframeConfig: { iframeContainerId: string; }
iframeConfig
: {
iframeContainerId: string
iframeContainerId
: "alchemy-signer-iframe-container",
}, }, });

If there is an existing session, then your signer is ready for use! If not, see the section above for logging users in.