The connect function stores the user's address in local storage by default, making it easy to persist the user's session across page reloads and browser sessions.
connect.ts
import{ connect }from'@stacks/connect';
constresponse=awaitconnect();
To access the user's addresses, you can use the getLocalStorage function.
storage.ts
import{ getLocalStorage }from'@stacks/connect';
constdata=getLocalStorage();
You can manage the connection's state using the following:
The process of connecting to a wallet gives the web app information about the wallet account, which enables interactions with the Stacks blockchain, like calling smart contracts.
Using the request function, you can trigger wallet interactions using the stx_transferStx method.
connect.tsx
constresponse=awaitrequest('stx_transferStx', {
amount:'1000',// amount in micro-STX (1 STX = 1,000,000 micro-STX)