@starknet-io/get-starknet
Version:
[](https://www.npmjs.com/package/@starknet-io/get-starknet)
106 lines (80 loc) âĸ 2.67 kB
Markdown
[](https://www.npmjs.com/package/@starknet-io/get-starknet)
- â¤ī¸â𩹠Allow Starknet dApps and wallets to seamlessly connect
- đĒļ Lightweight and easy to use
- đ Fast integration, building and testing
- âī¸ Customizable and extensible
- đ Open source and controlled by the community
```
npm install @starknet-io/get-starknet starknet
yarn add @starknet-io/get-starknet starknet
pnpm add @starknet-io/get-starknet starknet
```
Read more about the new Starkent Dapp<>Wallet API in the
[](https://community.starknet.io/t/new-starknet-wallet-dapp-api/114295)
You can use the built-in UI to connect to any Starknet wallet as fast as
possible like this:
```tsx
import { connect, disconnect } from "@starknet-io/get-starknet"
return <button onClick={() => connect()}>Connect wallet</button>
```
You can also choose to customize the UI by overwriting the CSS classes, or by
implementing your very own UI. This is possible due to a split into a `core` and
`ui` package. As a library author or dapp developer who wants to implement a
custom UI, you can use the `core` package.
```tsx
import {
disconnect,
enable,
getAvailableWallets,
getDiscoveryWallets,
getLastConnectedWallet,
getPreAuthorizedWallets,
} from "@starknet-io/get-starknet-core"
interface GetStarknetResult {
// Returns all wallets available in the window object
getAvailableWallets: (
options?: GetWalletOptions,
) => Promise<StarknetWindowObject[]>
// Returns only preauthorized wallets available in the window object
getPreAuthorizedWallets: (
options?: GetWalletOptions,
) => Promise<StarknetWindowObject[]>
// Returns all wallets in existence (from discovery file)
getDiscoveryWallets: (options?: GetWalletOptions) => Promise<WalletProvider[]>
// Returns the last wallet connected when it's still connected
getLastConnectedWallet: () => Promise<StarknetWindowObject | null>
// Connects to a wallet
enable: (
wallet: StarknetWindowObject,
options?: {
starknetVersion?: "v4" | "v5"
},
) => Promise<ConnectedStarknetWindowObject>
// Disconnects from a wallet
disconnect: (options?: { clearLastWallet?: boolean }) => Promise<void>
}
```
You need Node and pnpm installed. Make sure to clone this repo and run:
```bash
pnpm install
pnpm build
```
To start watching for changes, run:
```bash
pnpm dev
```
and open `http://localhost:5173/`
For running tests:
```bash
pnpm test
```