Connect is a JavaScript library for building web applications connected to Stacks.
Stacks Connect enables you to authenticate your users and connect your app to their wallet. This reference contains more detailed information on how you can authenticate users, sign and broadcast transactions on their behalf, and enable users to sign messages.
Migration Note
Please be patient during the migration to version 8.x.x. There has been a long-running effort together with wallets to modernize the Stacks web ecosystem, culminating in SIP-030 and the new request method in Stacks Connect 8.x.x. For the legacy version of @stacks/connect using JWT tokens, please use version 7.10.1. See the Migration Guide for more details.
The request method returns a Promise, allowing you to handle errors using standard Promise-based error handling patterns. You can use either try/catch with async/await or the .catch() method with Promise chains.
The request method by default adds a layer of auto-compatibility for different wallet providers. This is meant to unify the interface where wallet providers may not implement methods and results the same way.
Wallet Support
For a complete list of wallet compatibility and support status, see the Wallet Support page.
enableLocalStorage?:boolean;// Store address in local storage (default: true)
defaultProviders?:WbipProvider[];// Default wallets to display in modal
approvedProviderIds?:string[];// List of approved provider IDs to show in modal
},
'method',
params
);
// WITHOUT options
constresponse=awaitrequest('method', params);
Provider Compatibility
The enableOverrides option enables automatic compatibility fixes for different wallet providers. For example, it handles converting numeric types between string and number formats as needed by different wallets, and remaps certain method names to match wallet-specific implementations. This ensures consistent behavior across different wallet providers without requiring manual adjustments.
Approved Providers
The approvedProviderIds option allows you to filter which wallet providers are shown in the connect modal. This is useful when you want to limit the available wallet options to specific providers. For example, you might only want to support Leather wallet:
requestRaw bypasses the UI wallet selector, automatic provider compatibility fixes, and other features that come with request. Use this when you need more manual control over the wallet interaction process.