disconnect
Action for disconnecting from a StarkNet wallet.
Import
import { disconnect } from "starkweb/core";
Usage
index.ts
import { disconnect } from "starkweb/core";
import { config } from "./config";
await disconnect(config);
Parameters
import { type DisconnectParameters } from "starkweb/core";
connector (optional)
Connector | undefined
The specific connector to disconnect from. If not provided, will disconnect from the current connector.
index.ts
import { disconnect } from "starkweb/core";
import { injected } from "starkweb/connectors";
import { config } from "./config";
const connector = injected();
await disconnect(config, {
connector,
});
Return Type
import { type DisconnectReturnType } from "starkweb/core";
void
The disconnect action doesn't return any value.
Example
example.ts
import { disconnect, getAccount } from "starkweb/core";
import { config } from "./config";
// Check if connected before disconnecting
const account = getAccount(config);
if (account.isConnected) {
// Disconnect from current connector
await disconnect(config);
console.log("Wallet disconnected");
}
// Disconnect from a specific connector
import { injected } from "starkweb/connectors";
const connector = injected();
await disconnect(config, {
connector,
});
Error
import { type DisconnectErrorType } from "starkweb/core";
TanStack Query
import {
type DisconnectData,
type DisconnectVariables,
type DisconnectMutate,
type DisconnectMutateAsync,
disconnectMutationOptions,
} from "starkweb/query";