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 signersigner } 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: anyuser = await import signersigner.anygetAuthDetails().anycatch(() => null);
import { class AlchemyWebSignerA SmartAccountSigner that can be used with any SmartContractAccount
AlchemyWebSigner } from "@account-kit/signer";
export const const signer: AlchemyWebSignersigner = new new AlchemyWebSigner(params: AlchemySignerParams): AlchemyWebSignerInitializes 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: stringapiKey: "API_KEY",
},
iframeConfig: {
iframeContainerId: string;
}iframeConfig: {
iframeContainerId: stringiframeContainerId: "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.