# __thirdweb TypeScript SDK Documentation__
> Frontend, Backend, and Onchain tools to build complete web3 apps — on every EVM chain.
---
**UI Components**
---
# Wallets
---
## AccountAddress
### Example
#### Basic usage
```tsx
import { AccountProvider, AccountAddress } from "thirdweb/react";
;
```
Result:
```html
0x12345674b599ce99958242b3D3741e7b01841DF3
```
#### Shorten the address
```tsx
import { AccountProvider, AccountAddress } from "thirdweb/react";
import { shortenAddress } from "thirdweb/utils";
;
```
Result:
```html
0x1234...1DF3
```
```ts
function AccountAddress(
__namedParameters: AccountAddressProps,
): Element;
```
### Parameters
#### Type
```ts
let __namedParameters: {about : string,accessKey : string,aria-activedescendant : string,aria-atomic : Booleanish,aria-autocomplete : "inline" | "none" | "list" | "both",aria-braillelabel : string,aria-brailleroledescription : string,aria-busy : Booleanish,aria-checked : boolean | "false" | "true" | "mixed",aria-colcount : number,aria-colindex : number,aria-colindextext : string,aria-colspan : number,aria-controls : string,aria-current : boolean | "false" | "true" | "time" | "step" | "page" | "location" | "date",aria-describedby : string,aria-description : string,aria-details : string,aria-disabled : Booleanish,aria-dropeffect : "link" | "popup" | "execute" | "none" | "copy" | "move",aria-errormessage : string,aria-expanded : Booleanish,aria-flowto : string,aria-grabbed : Booleanish,aria-haspopup : boolean | "false" | "true" | "dialog" | "menu" | "grid" | "tree" | "listbox",aria-hidden : Booleanish,aria-invalid : boolean | "false" | "true" | "grammar" | "spelling",aria-keyshortcuts : string,aria-label : string,aria-labelledby : string,aria-level : number,aria-live : "off" | "polite" | "assertive",aria-modal : Booleanish,aria-multiline : Booleanish,aria-multiselectable : Booleanish,aria-orientation : "horizontal" | "vertical",aria-owns : string,aria-placeholder : string,aria-posinset : number,aria-pressed : boolean | "false" | "true" | "mixed",aria-readonly : Booleanish,aria-relevant : "text" | "all" | "additions" | "additions removals" | "additions text" | "removals" | "removals additions" | "removals text" | "text additions" | "text removals",aria-required : Booleanish,aria-roledescription : string,aria-rowcount : number,aria-rowindex : number,aria-rowindextext : string,aria-rowspan : number,aria-selected : Booleanish,aria-setsize : number,aria-sort : "none" | "ascending" | "descending" | "other",aria-valuemax : number,aria-valuemin : number,aria-valuenow : number,aria-valuetext : string,autoCapitalize : (string & ({ })) | "on" | "off" | "none" | "sentences" | "words" | "characters",autoCorrect : string,autoFocus : boolean,autoSave : string,className : string,color : string,content : string,contentEditable : "inherit" | (Booleanish) | "plaintext-only",contextMenu : string,dangerouslySetInnerHTML : { __html: string | (TrustedHTML) },datatype : string,defaultChecked : boolean,defaultValue : string | number | (readonly Array),dir : string,draggable : Booleanish,enterKeyHint : "search" | "done" | "next" | "send" | "enter" | "go" | "previous",formatFn : (str: string) => string,hidden : boolean,id : string,inert : boolean,inlist : any,inputMode : "search" | "email" | "url" | "text" | "none" | "tel" | "numeric" | "decimal",is : string,itemID : string,itemProp : string,itemRef : string,itemScope : boolean,itemType : string,lang : string,nonce : string,onAbort : ReactEventHandler,onAbortCapture : ReactEventHandler,onAnimationEnd : AnimationEventHandler,onAnimationEndCapture : AnimationEventHandler,onAnimationIteration : AnimationEventHandler,onAnimationIterationCapture : AnimationEventHandler,onAnimationStart : AnimationEventHandler,onAnimationStartCapture : AnimationEventHandler,onAuxClick : MouseEventHandler,onAuxClickCapture : MouseEventHandler,onBeforeInput : FormEventHandler,onBeforeInputCapture : FormEventHandler,onBeforeToggle : ToggleEventHandler,onBlur : FocusEventHandler,onBlurCapture : FocusEventHandler,onCanPlay : ReactEventHandler,onCanPlayCapture : ReactEventHandler,onCanPlayThrough : ReactEventHandler,onCanPlayThroughCapture : ReactEventHandler,onChange : FormEventHandler,onChangeCapture : FormEventHandler,onClick : MouseEventHandler,onClickCapture : MouseEventHandler,onCompositionEnd : CompositionEventHandler,onCompositionEndCapture : CompositionEventHandler,onCompositionStart : CompositionEventHandler,onCompositionStartCapture : CompositionEventHandler,onCompositionUpdate : CompositionEventHandler,onCompositionUpdateCapture : CompositionEventHandler,onContextMenu : MouseEventHandler,onContextMenuCapture : MouseEventHandler,onCopy : ClipboardEventHandler,onCopyCapture : ClipboardEventHandler,onCut : ClipboardEventHandler,onCutCapture : ClipboardEventHandler,onDoubleClick : MouseEventHandler,onDoubleClickCapture : MouseEventHandler,onDrag : DragEventHandler,onDragCapture : DragEventHandler,onDragEnd : DragEventHandler,onDragEndCapture : DragEventHandler,onDragEnter : DragEventHandler,onDragEnterCapture : DragEventHandler,onDragExit : DragEventHandler,onDragExitCapture : DragEventHandler,onDragLeave : DragEventHandler,onDragLeaveCapture : DragEventHandler,onDragOver : DragEventHandler,onDragOverCapture : DragEventHandler,onDragStart : DragEventHandler,onDragStartCapture : DragEventHandler,onDrop : DragEventHandler,onDropCapture : DragEventHandler,onDurationChange : ReactEventHandler,onDurationChangeCapture : ReactEventHandler,onEmptied : ReactEventHandler,onEmptiedCapture : ReactEventHandler,onEncrypted : ReactEventHandler,onEncryptedCapture : ReactEventHandler,onEnded : ReactEventHandler,onEndedCapture : ReactEventHandler,onError : ReactEventHandler,onErrorCapture : ReactEventHandler,onFocus : FocusEventHandler,onFocusCapture : FocusEventHandler,onGotPointerCapture : PointerEventHandler,onGotPointerCaptureCapture : PointerEventHandler,onInput : FormEventHandler,onInputCapture : FormEventHandler,onInvalid : FormEventHandler,onInvalidCapture : FormEventHandler,onKeyDown : KeyboardEventHandler,onKeyDownCapture : KeyboardEventHandler,onKeyPress : KeyboardEventHandler,onKeyPressCapture : KeyboardEventHandler,onKeyUp : KeyboardEventHandler,onKeyUpCapture : KeyboardEventHandler,onLoad : ReactEventHandler,onLoadCapture : ReactEventHandler,onLoadedData : ReactEventHandler,onLoadedDataCapture : ReactEventHandler,onLoadedMetadata : ReactEventHandler,onLoadedMetadataCapture : ReactEventHandler,onLoadStart : ReactEventHandler,onLoadStartCapture : ReactEventHandler,onLostPointerCapture : PointerEventHandler,onLostPointerCaptureCapture : PointerEventHandler,onMouseDown : MouseEventHandler,onMouseDownCapture : MouseEventHandler,onMouseEnter : MouseEventHandler,onMouseLeave : MouseEventHandler,onMouseMove : MouseEventHandler,onMouseMoveCapture : MouseEventHandler,onMouseOut : MouseEventHandler,onMouseOutCapture : MouseEventHandler,onMouseOver : MouseEventHandler,onMouseOverCapture : MouseEventHandler,onMouseUp : MouseEventHandler,onMouseUpCapture : MouseEventHandler,onPaste : ClipboardEventHandler,onPasteCapture : ClipboardEventHandler,onPause : ReactEventHandler,onPauseCapture : ReactEventHandler,onPlay : ReactEventHandler,onPlayCapture : ReactEventHandler,onPlaying : ReactEventHandler,onPlayingCapture : ReactEventHandler,onPointerCancel : PointerEventHandler,onPointerCancelCapture : PointerEventHandler,onPointerDown : PointerEventHandler,onPointerDownCapture : PointerEventHandler,onPointerEnter : PointerEventHandler,onPointerLeave : PointerEventHandler,onPointerMove : PointerEventHandler,onPointerMoveCapture : PointerEventHandler,onPointerOut : PointerEventHandler,onPointerOutCapture : PointerEventHandler,onPointerOver : PointerEventHandler,onPointerOverCapture : PointerEventHandler,onPointerUp : PointerEventHandler,onPointerUpCapture : PointerEventHandler,onProgress : ReactEventHandler,onProgressCapture : ReactEventHandler,onRateChange : ReactEventHandler,onRateChangeCapture : ReactEventHandler,onReset : FormEventHandler,onResetCapture : FormEventHandler,onResize : ReactEventHandler,onResizeCapture : ReactEventHandler,onScroll : UIEventHandler,onScrollCapture : UIEventHandler,onSeeked : ReactEventHandler,onSeekedCapture : ReactEventHandler,onSeeking : ReactEventHandler,onSeekingCapture : ReactEventHandler,onSelect : ReactEventHandler,onSelectCapture : ReactEventHandler,onStalled : ReactEventHandler,onStalledCapture : ReactEventHandler,onSubmit : FormEventHandler,onSubmitCapture : FormEventHandler,onSuspend : ReactEventHandler,onSuspendCapture : ReactEventHandler,onTimeUpdate : ReactEventHandler,onTimeUpdateCapture : ReactEventHandler,onToggle : ToggleEventHandler,onTouchCancel : TouchEventHandler,onTouchCancelCapture : TouchEventHandler,onTouchEnd : TouchEventHandler,onTouchEndCapture : TouchEventHandler,onTouchMove : TouchEventHandler,onTouchMoveCapture : TouchEventHandler,onTouchStart : TouchEventHandler,onTouchStartCapture : TouchEventHandler,onTransitionCancel : TransitionEventHandler,onTransitionCancelCapture : TransitionEventHandler,onTransitionEnd : TransitionEventHandler,onTransitionEndCapture : TransitionEventHandler,onTransitionRun : TransitionEventHandler,onTransitionRunCapture : TransitionEventHandler,onTransitionStart : TransitionEventHandler,onTransitionStartCapture : TransitionEventHandler,onVolumeChange : ReactEventHandler,onVolumeChangeCapture : ReactEventHandler,onWaiting : ReactEventHandler,onWaitingCapture : ReactEventHandler,onWheel : WheelEventHandler,onWheelCapture : WheelEventHandler,popover : "" | "auto" | "manual",popoverTarget : string,popoverTargetAction : "toggle" | "hide" | "show",prefix : string,property : string,radioGroup : string,rel : string,resource : string,results : number,rev : string,role : AriaRole,security : string,slot : string,spellCheck : Booleanish,style : CSSProperties,suppressContentEditableWarning : boolean,suppressHydrationWarning : boolean,tabIndex : number,title : string,translate : "yes" | "no",typeof : string,unselectable : "on" | "off",vocab : string}
```
### Returns
```ts
let returnType: Element;
```
a `` containing the full wallet address of the account
---
## AccountBlobbie
A wrapper for the Blobbie component
```ts
function AccountBlobbie(
props: Omit,
): Element;
```
### Parameters
BlobbieProps
#### Type
```ts
let props: Omit;
```
### Returns
```ts
let returnType: Element;
```
---
## AccountProvider
A React context provider component that supplies Account-related data to its child components.
This component serves as a wrapper around the `AccountProviderContext.Provider` and passes the provided account data down to all of its child components through the context API.
### Example
```tsx
import {
AccountProvider,
AccountAvatar,
AccountName,
AccountAddress,
} from "thirdweb/react";
;
```
```ts
function AccountProvider(
props: PropsWithChildren,
): Element;
```
### Parameters
#### Type
```ts
let props: PropsWithChildren;
```
### Returns
```ts
let returnType: Element;
```
---
## Blobbie
A unique gradient avatar based on the provided address.
### Example
```tsx
import { Blobbie } from "thirdweb/react";
;
```
```ts
function Blobbie(props: BlobbieProps): Element;
```
### Parameters
The component props.
#### Type
```ts
let props: BlobbieProps;
```
### Returns
```ts
let returnType: Element;
```
---
## WalletProvider
/\*\*
* A React context provider component that supplies Wallet-related data to its child components.
* This component serves as a wrapper around the `WalletProviderContext.Provider` and passes
* the provided wallet data down to all of its child components through the context API.
### Example
* #### Basic usage
* ```tsx
```
* import { WalletProvider, WalletIcon, WalletName } from "thirdweb/react";
* ``
* ``
* ``
* ``
```ts
function WalletProvider(
props: PropsWithChildren,
): Element;
```
### Parameters
#### Type
```ts
let props: PropsWithChildren;
```
### Returns
```ts
let returnType: Element;
```
---
# Wallet Connection
---
## AutoConnectProps
```ts
type AutoConnectProps = {
accountAbstraction?: SmartWalletOptions;
appMetadata?: AppMetadata;
chain?: Chain;
client: ThirdwebClient;
onConnect?: (wallet: Wallet) => void;
onTimeout?: () => void;
timeout?: number;
wallets?: Array;
};
```
Enable Account abstraction for all wallets. This will connect to the users's smart account based on the connected personal wallet and the given options.
If you are connecting to smart wallet using personal wallet - setting this configuration will autoConnect the personal wallet and then connect to the smart wallet.
```tsx
```
```ts
type accountAbstraction = SmartWalletOptions;
```
Metadata of the app that will be passed to connected wallet. Setting this is highly recommended.
Some wallets display this information to the user when they connect to your app.
```ts
type appMetadata = AppMetadata;
```
### Example
```ts
{
name: "My App",
url: "https://my-app.com",
description: "some description about your app",
logoUrl: "https://path/to/my-app/logo.svg",
};
```
Optional chain to autoconnect to
```ts
type chain = Chain;
```
A client is the entry point to the thirdweb SDK. It is required for all other actions. You can create a client using the `createThirdwebClient` function. Refer to the [ Creating a Client](https://portal.thirdweb.com/typescript/v5/client) documentation for more information.
You must provide a `clientId` or `secretKey` in order to initialize a client. Pass `clientId` if you want for client-side usage and `secretKey` for server-side usage.
```tsx
import { createThirdwebClient } from "thirdweb";
const client = createThirdwebClient({
clientId: "",
});
```
```ts
type client = ThirdwebClient;
```
```ts
function onConnect(wallet: Wallet): void;
```
##### Parameters
###### Type
```ts
let wallet: {
getAdminAccount?: () => Account | undefined;
getConfig: () => CreateWalletArgs[1];
id: TWalletId;
onConnectRequested?: () => Promise;
subscribe: WalletEmitter["subscribe"];
autoConnect: (
options: WalletAutoConnectionOption,
) => Promise;
connect: (
options: WalletConnectionOption,
) => Promise;
disconnect: () => Promise;
getAccount: () => undefined | Account;
getChain: () =>
| undefined
| Readonly;
switchChain: (
chain: Readonly,
) => Promise;
};
```
##### Returns
```ts
let returnType: void;
```
```ts
function onTimeout(): void;
```
##### Returns
```ts
let returnType: void;
```
if the autoConnection does not succeed within given timeout in milliseconds, it will be cancelled.
By default, the timeout is set to 15000ms (15 seconds).
```tsx
;
```
```ts
type timeout = number;
```
Array of wallets that your app uses
```ts
type wallets = Array;
```
### Example
```tsx
import { AutoConnect } from "thirdweb/react";
import { createWallet, inAppWallet } from "thirdweb/wallets";
const wallets = [
inAppWallet(),
createWallet("io.metamask"),
createWallet("com.coinbase.wallet"),
createWallet("me.rainbow"),
];
function Example() {
return ;
}
```
---
## ConnectButton
A fully featured wallet connection component that allows to:
* Connect to 500+ external wallets
* Connect with email, phone, passkey or socials
* Convert any wallet to a ERC4337 smart wallet for gasless transactions
* Sign in with ethereum (Auth)
Once connected, the component allows to:
* Reolve ENS names and avatars
* Manage multipple connected wallets
* Send and receive native tokens and ERC20 tokens
* View ERC20 tokens and NFTs
* Onramp, bridge and swap tokens
* Switch chains
* Connect to another app with WalletConnect
### Example
### Default setup
```tsx
import { createThirdwebClient } from "thirdweb";
import { ConnectButton } from "thirdweb/react";
const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID" });
;
```
[ View all available config options](https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps)
### Customization options
#### Customizing wallet options
```tsx
;
```
[ View all available wallets](https://portal.thirdweb.com/typescript/v5/supported-wallets)
#### Customizing the default chain to connect to
```tsx
import { sepolia } from "thirdweb/chains";
;
```
#### Enabling Account Abstraction
By passing the `accountAbstraction` prop, ALL connected wallets will be converted to smart accounts. And by setting `sponsorGas` to `true` , all transactions done with those smart accounts will be sponsored.
```tsx
;
```
Note that this prop doesn't affect ecosystem wallets. Ecosystem wallets will only be converted to smart accounts if the ecosystem owner has enabled account abstraction.
#### Enabling sign in with ethereum (Auth)
```tsx
{
console.log("checking if logged in!", { address });
return await isLoggedIn();
},
doLogin: async (params) => {
console.log("logging in!");
await login(params);
},
getLoginPayload: async ({ address }) =>
generatePayload({ address }),
doLogout: async () => {
console.log("logging out!");
await logout();
},
}}
/>;
```
#### Customizing the theme
```tsx
;
```
For more granular control, you can also pass a custom theme object:
```tsx
;
```
[ View all available themes properties](https://portal.thirdweb.com/references/typescript/v5/Theme)
#### Changing the display language
```tsx
;
```
[ View all available locales](https://portal.thirdweb.com/references/typescript/v5/LocaleId)
#### Customizing the connect button UI
```tsx
;
```
#### Customizing the modal UI
```tsx
;
```
#### Customizing details button UI (after connecting)
```tsx
;
```
[ View all available auth helper functions](https://portal.thirdweb.com/references/typescript/v5/createAuth)
#### Customizing the Auth sign in button (after connecting, but before authenticating)
```tsx
;
```
#### Customizing supported Tokens and NFTs
These tokens and NFTs will be shown in the modal when the user clicks "View Assets", as well as the send token screen.
```tsx
;
```
#### Customizing the orders of the tabs in the \[View Funds\] screen
When you click on "View Assets", by default the "Tokens" tab is shown first. If you want to show the "NFTs" tab first, change the order of the asset tabs to: \["nft", "token"\] Note: If an empty array is passed, the \[View Funds\] button will be hidden
```tsx
;
```
#### Callback for when the details modal is closed
```tsx
{
console.log({ screen });
},
}}
/>;
```
```ts
function ConnectButton(props: ConnectButtonProps): Element;
```
### Parameters
Props for the `ConnectButton` component
Refer to [ ConnectButtonProps](https://portal.thirdweb.com/references/typescript/v5/ConnectButtonProps) to see the available props.
#### Type
```ts
let props: {
accountAbstraction?: SmartWalletOptions;
appMetadata?: AppMetadata;
auth?: SiweAuthOptions;
autoConnect?: { timeout: number } | boolean;
chain?: Chain;
chains?: Array;
client: ThirdwebClient;
connectButton?: ConnectButton_connectButtonOptions;
connectModal?: ConnectButton_connectModalOptions;
detailsButton?: ConnectButton_detailsButtonOptions;
detailsModal?: ConnectButton_detailsModalOptions;
locale?: LocaleId;
onConnect?: (wallet: Wallet) => void;
onDisconnect?: (info: { account: Account; wallet: Wallet }) => void;
recommendedWallets?: Array;
showAllWallets?: boolean;
signInButton?: {
className?: string;
label?: string;
style?: React.CSSProperties;
};
supportedNFTs?: SupportedNFTs;
supportedTokens?: SupportedTokens;
switchButton?: {
className?: string;
label?: string;
style?: React.CSSProperties;
};
theme?: "dark" | "light" | Theme;
walletConnect?: { projectId?: string };
wallets?: Array;
};
```
### Returns
```ts
let returnType: Element;
```
A JSX element that renders the `` component.
---
## ConnectEmbed
An inline wallet connection component that allows to:
* Connect to 500+ external wallets
* Connect with email, phone, passkey or socials
* Convert any wallet to a ERC4337 smart wallet for gasless transactions
* Sign in with ethereum (Auth)
It renders the same UI as the [ConnectButton](https://portal.thirdweb.com/react/v5/ConnectButton) component's modal - but directly inline in the page instead of being in a modal.
Once connected, the component does not render any UI. It only renders UI if wallet is not connected.
### Example
### Default setup
```tsx
import { createThirdwebClient } from "thirdweb";
import { ConnectEmbed } from "thirdweb/react";
const client = createThirdwebClient({ clientId: "YOUR_CLIENT_ID" });
;
```
[ View all available config options](https://portal.thirdweb.com/references/typescript/v5/ConnectEmbedProps)
### Customization options
#### Customizing wallet options
```tsx
;
```
[ View all available wallets](https://portal.thirdweb.com/typescript/v5/supported-wallets)
#### Customizing the default chain to connect to
```tsx
import { base } from "thirdweb/chains";
;
```
#### Enabling Account Abstraction
By passing the `accountAbstraction` prop, ALL connected wallets will be converted to smart accounts. And by setting `sponsorGas` to `true` , all transactions done with those smart accounts will be sponsored.
```tsx
;
```
Note that this prop doesn't affect ecosystem wallets. Ecosystem wallets will only be converted to smart accounts if the ecosystem owner has enabled account abstraction.
#### Enabling sign in with ethereum (Auth)
```tsx
{
console.log("checking if logged in!", { address });
return await isLoggedIn();
},
doLogin: async (params) => {
console.log("logging in!");
await login(params);
},
getLoginPayload: async ({ address }) =>
generatePayload({ address }),
doLogout: async () => {
console.log("logging out!");
await logout();
},
}}
/>;
```
#### Customizing the theme
```tsx
;
```
For more granular control, you can also pass a custom theme object:
```tsx
;
```
[ View all available themes properties](https://portal.thirdweb.com/references/typescript/v5/Theme)
#### Changing the display language
```tsx
;
```
[ View all available locales](https://portal.thirdweb.com/references/typescript/v5/LocaleId)
```ts
function ConnectEmbed(props: ConnectEmbedProps): Element;
```
### Parameters
The props for the `ConnectEmbed` component.
Refer to the [ConnectEmbedProps](https://portal.thirdweb.com/references/typescript/v5/ConnectEmbedProps) type for more details
#### Type
```ts
let props: {
accountAbstraction?: SmartWalletOptions;
appMetadata?: AppMetadata;
auth?: SiweAuthOptions;
autoConnect?: { timeout: number } | boolean;
chain?: Chain;
chains?: Array;
className?: string;
client: ThirdwebClient;
header?: { title?: string; titleIcon?: string } | true;
locale?: LocaleId;
modalSize?: "compact" | "wide";
onConnect?: (wallet: Wallet) => void;
privacyPolicyUrl?: string;
recommendedWallets?: Array;
requireApproval?: boolean;
showAllWallets?: boolean;
showThirdwebBranding?: boolean;
style?: React.CSSProperties;
termsOfServiceUrl?: string;
theme?: "dark" | "light" | Theme;
walletConnect?: { projectId?: string };
wallets?: Array;
welcomeScreen?: WelcomeScreen;
};
```
### Returns
```ts
let returnType: Element;
```
A JSX element that renders the `` component.
---
## SiteEmbed
Embeds another thirdweb-supported site for seamless in-app and ecosystem wallet connection.
Make sure the embedded site includes `` and supports frame ancestors, see [ here](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy/frame-ancestors) for more information.
The embedded site must support the connected wallet (ecosystem or in-app).
### Example
```tsx
import { SiteEmbed } from "thirdweb/react";
;
```
```ts
function SiteEmbed(
props: {
client: ThirdwebClient;
ecosystem?: Ecosystem;
src: string;
} & ClassAttributes &
IframeHTMLAttributes,
): Element;
```
### Parameters
The props to pass to the iframe
#### Type
```ts
let props: {
client: ThirdwebClient;
ecosystem?: Ecosystem;
src: string;
} & ClassAttributes &
IframeHTMLAttributes;
```
### Returns
```ts
let returnType: Element;
```
---
## SiteLink
Creates a link to another thirdweb-supported site with wallet connection parameters.
The target site must support the connected wallet (ecosystem or in-app).
### Example
```tsx
import { SiteLink } from "thirdweb/react";
Visit Site
;
```
```ts
function SiteLink(
props: {
children: ReactNode;
client: ThirdwebClient;
ecosystem?: Ecosystem;
href: string;
} & Omit, "href">,
): Element;
```
### Parameters
The props to pass to the anchor tag
#### Type
```ts
let props: {
children: ReactNode;
client: ThirdwebClient;
ecosystem?: Ecosystem;
href: string;
} & Omit, "href">;
```
### Returns
```ts
let returnType: Element;
```
---
## ThirdwebProvider
The ThirdwebProvider is component is a provider component that sets up the React Query client.
### Example
```jsx
import { ThirdwebProvider } from "thirdweb/react";
function Example() {
return (
);
}
```
```ts
function ThirdwebProvider(
props: PropsWithChildren<{
connectionManager?: {
activeAccountStore: Store;
activeWalletChainStore: Store<
undefined | Readonly
>;
activeWalletConnectionStatusStore: Store;
activeWalletStore: Store;
addConnectedWallet: (wallet: Wallet) => void;
connect: (
wallet: Wallet,
options?: ConnectManagerOptions,
) => Promise;
connectedWallets: ReadonlyStore>;
defineChains: (
chains: Array>,
) => void;
disconnectWallet: (wallet: Wallet) => void;
handleConnection: (
wallet: Wallet,
options?: ConnectManagerOptions,
) => Promise;
isAutoConnecting: Store;
removeConnectedWallet: (wallet: Wallet) => void;
setActiveWallet: (activeWallet: Wallet) => Promise;
switchActiveWalletChain: (
chain: Readonly,
) => Promise;
};
}>,
): Element;
```
### Parameters
The props for the ThirdwebProvider
#### Type
```ts
let props: PropsWithChildren<{
connectionManager?: {
activeAccountStore: Store;
activeWalletChainStore: Store<
undefined | Readonly
>;
activeWalletConnectionStatusStore: Store;
activeWalletStore: Store;
addConnectedWallet: (wallet: Wallet) => void;
connect: (
wallet: Wallet,
options?: ConnectManagerOptions,
) => Promise;
connectedWallets: ReadonlyStore>;
defineChains: (
chains: Array>,
) => void;
disconnectWallet: (wallet: Wallet) => void;
handleConnection: (
wallet: Wallet,
options?: ConnectManagerOptions,
) => Promise;
isAutoConnecting: Store;
removeConnectedWallet: (wallet: Wallet) => void;
setActiveWallet: (activeWallet: Wallet) => Promise;
switchActiveWalletChain: (
chain: Readonly,
) => Promise;
};
}>;
```
### Returns
```ts
let returnType: Element;
```
---
# Chain
---
## ChainProvider
A React context provider component that supplies Chain-related data to its child components.
This component serves as a wrapper around the `ChainProviderContext.Provider` and passes the provided chain data down to all of its child components through the context API.
### Example
#### Basic usage
```tsx
import { ChainProvider, ChainIcon, ChainName } from "thirdweb/react";
import { ethereum } from "thirdweb/chains";
;
```
#### Usage with defineChain
```tsx
import { defineChain } from "thirdweb/chains"l
import { ChainProvider, ChainName } from "thirdweb/react";
const chainId = someNumber;
```
```ts
function ChainProvider(
props: PropsWithChildren,
): Element;
```
### Parameters
#### Type
```ts
let props: PropsWithChildren;
```
### Returns
```ts
let returnType: Element;
```
---
# Transactions
---
## BuyDirectListingButton
This button is used with thirdweb Marketplace v3 contract, for buying NFT(s) from a listing.
Under the hood, it prepares a transaction using the [buyFromListing extension](https://portal.thirdweb.com/references/typescript/v5/marketplace/buyFromListing)and then pass it to a ``
Since it uses the TransactionButton, it can take in any props that can be passed to the [TransactionButton](https://portal.thirdweb.com/references/typescript/v5/TransactionButton)
### Example
```tsx
import { BuyDirectListingButton } from "thirdweb/react";
Buy NFT
```
For error handling & callbacks on transaction-sent and transaction-confirmed, please refer to the TransactionButton docs.
```ts
function BuyDirectListingButton(
props: BuyDirectListingButtonProps,
): Element;
```
### Parameters
#### Type
```ts
let props: Omit & {
chain: Chain;
client: ThirdwebClient;
contractAddress: string;
listingId: bigint;
quantity?: bigint;
};
```
### Returns
```ts
let returnType: Element;
```
``
---
## ClaimButton
This button is used to claim tokens (NFT or ERC20) from a given thirdweb Drop contract.
there are 3 type of Drop contract: NFT Drop (DropERC721), Edition Drop (DropERC1155) and Token Drop (DropERC20)
Learn more: https://thirdweb.com/explore/drops
Note: This button only works with thirdweb Drop contracts. For custom contract, please use [TransactionButton](https://portal.thirdweb.com/references/typescript/v5/TransactionButton)
### Example
Example for claiming NFT from an NFT Drop contract
```tsx
import { ClaimButton } from "thirdweb/react";
import { ethereum } from "thirdweb/chains";
Claim now
;
```
For Edition Drop (ERC1155)
```tsx
Claim now
;
```
For Token Drop (ERC20)
```tsx
Claim now
;
```
Attach custom Pay metadata
```tsx
...
;
```
Since this button uses the `TransactionButton` , it can take in any props that can be passed to the [TransactionButton](https://portal.thirdweb.com/references/typescript/v5/TransactionButton)
For error handling & callbacks on transaction-sent and transaction-confirmed, please refer to the TransactionButton docs.
```ts
function ClaimButton(props: ClaimButtonProps): Element;
```
### Parameters
#### Type
```ts
let props: Omit & {
chain: Chain;
claimParams: ClaimParams;
client: ThirdwebClient;
contractAddress: string;
};
```
### Returns
```ts
let returnType: Element;
```
A wrapper for TransactionButton
---
## CreateDirectListingButton
This button is used to create Direct listings for the thirdweb Marketplace v3 contract
It uses the [TransactionButton](https://portal.thirdweb.com/references/typescript/v5/TransactionButton)and the [createListing extension](https://portal.thirdweb.com/references/typescript/v5/marketplace/createListing) under the hood which means it inherits all the props of those 2 components.
### Example
```tsx
import { CreateDirectListingButton } from "thirdweb/react";
>
Sell NFT
```
For error handling & callbacks on transaction-sent and transaction-confirmed, please refer to the TransactionButton docs.
```ts
function CreateDirectListingButton(
props: CreateDirectListingButtonProps,
): Element;
```
### Parameters
#### Type
```ts
let props: Omit &
CreateListingParams & {
chain: Chain;
client: ThirdwebClient;
contractAddress: string;
};
```
### Returns
```ts
let returnType: Element;
```
---
## TransactionButton
TransactionButton component is used to render a button that triggers a transaction. It shows a "Switch Network" button if the connected wallet is on a different chain than the transaction.
### Example
#### Basic usage
```tsx
{}}
onTransactionConfirmed={handleSuccess}
onError={handleError}
>
Confirm Transaction
;
```
#### Customize the styling by passing the `unstyled` prop and your inline styles and/or classes:
```tsx
{}}
unstyled
className="bg-white text-black rounded-md p-4 flex items-center justify-center"
>
Confirm Transaction
;
```
#### Handle errors
```tsx
...}
onError={(err) => {
alert(err.message);
// Add your own logic here
}}
>
Confirm Transaction
```
#### Alert when a transaction is sent
```tsx
...}
onTransactionSent={(tx) => {
alert("transaction sent!");
// Add your own logic here. For example, a toast
}}
>
Confirm Transaction
```
#### Alert when a transaction is completed
```tsx
...}
onTransactionConfirmed={(tx) => {
alert("transaction sent!");
console.log(tx);
// Add your own logic here. For example, a toast
}}
>
Confirm Transaction
```
#### The onClick prop, if provided, will be called before the transaction is sent.
```tsx
alert("Transaction is about to be sent")}
transaction={...}
>
...
```
#### Attach custom Pay metadata
```tsx
...
;
```
#### Gasless usage with [ thirdweb Engine](https://portal.thirdweb.com/engine)
```tsx
...
;
```
#### Gasless usage with OpenZeppelin
```tsx
...
;
```
```ts
function TransactionButton(props: TransactionButtonProps): Element;
```
### Parameters
The props for this component. Refer to [ TransactionButtonProps](https://portal.thirdweb.com/references/typescript/v5/TransactionButtonProps) for details.
#### Type
```ts
let props: {
children: React.ReactNode;
className?: string;
disabled?: boolean;
gasless?: GaslessOptions;
onClick?: () => void;
onError?: (error: Error) => void;
onTransactionConfirmed?: (receipt: TransactionReceipt) => void;
onTransactionSent?: (
transactionResult: WaitForReceiptOptions,
) => void;
payModal?: SendTransactionPayModalConfig;
style?: React.CSSProperties;
theme?: "dark" | "light" | Theme;
transaction: () =>
| PreparedTransaction
| Promise>;
type?: HTMLButtonElement["type"];
unstyled?: boolean;
};
```
### Returns
```ts
let returnType: Element;
```
---
# NFT
---
## NFTProvider
A React context provider component that supplies NFT-related data to its child components.
This component serves as a wrapper around the `NFTProviderContext.Provider` and passes the provided NFT data down to all of its child components through the context API.
### Example
```tsx
import { getContract } from "thirdweb";
import {
NFTProvider,
NFTMedia,
NFTDescription,
NFTName,
} from "thirdweb/react";
const contract = getContract({
address: "0x...",
chain: ethereum,
client: yourThirdwebClient,
});
;
```
```ts
function NFTProvider(
props: PropsWithChildren,
): Element;
```
### Parameters
The props for the NFT provider
#### Type
```ts
let props: PropsWithChildren;
```
### Returns
```ts
let returnType: Element;
```
---
# Tokens
---
## TokenProvider
A React context provider component that supplies Token-related data to its child components.
This component serves as a wrapper around the `TokenProviderContext.Provider` and passes the provided token data down to all of its child components through the context API.
### Example
#### Basic usage
```tsx
import { TokenProvider, TokenIcon, TokenName } from "thirdweb/react";
import { ethereum } from "thirdweb/chains";
```
#### This component also works with native token!
```tsx
import { NATIVE_TOKEN_ADDRESS } from "thirdweb";
import { ethereum } from "thirdweb/chains";
// "ETH"
;
```
```ts
function TokenProvider(
props: PropsWithChildren,
): Element;
```
### Parameters
#### Type
```ts
let props: PropsWithChildren;
```
### Returns
```ts
let returnType: Element;
```
---
# Miscellaneous
---
## MediaRenderer
```ts
function MediaRenderer(
props: MediaRendererProps & RefAttributes,
): ReactNode;
```
### Parameters
Refer to [MediaRendererProps](https://portal.thirdweb.com/references/typescript/v5/MediaRendererProps) to see the available props.
#### Type
```ts
let props: MediaRendererProps & RefAttributes;
```
### Returns
```ts
let returnType: ReactNode;
```
---
## PayEmbed
Embed a prebuilt UI for funding wallets, purchases or transactions with crypto or fiat.
### Example
#### Default configuration
By default, the `PayEmbed` component will allows users to fund their wallets with crypto or fiat on any of the supported chains..
```tsx
;
```
#### Top up wallets
You can set the `mode` option to `"fund_wallet"` to allow users to top up their wallets with crypto or fiat.
```tsx
;
```
#### Direct Payments
You can set the `mode` option to `"direct_payment"` to allow users to make a direct payment to a wallet address.
```tsx
;
```
#### Transactions
You can set the `mode` option to `"transaction"` to allow users to execute a transaction with a different wallet, chain or token.
```tsx
;
```
You can also handle ERC20 payments by passing `erc20value` to your transaction:
```tsx
```
#### Enable/Disable payment methods
You can disable the use of crypto or fiat by setting the `buyWithCrypto` or `buyWithFiat` options to `false` .
```tsx
### Customize the UI
You can customize the UI of the `PayEmbed` component by passing a custom theme object to the `theme` prop.
```tsx
```
Refer to the [Theme](https://portal.thirdweb.com/references/typescript/v5/Theme) type for more details.
#### Configure the wallet connection
You can customize the wallet connection flow by passing a `connectOptions` object to the `PayEmbed` component.
```tsx
;
```
Refer to the [PayEmbedConnectOptions](https://portal.thirdweb.com/references/typescript/v5/PayEmbedConnectOptions) type for more details.
@buyCrypto
```ts
function PayEmbed(props: PayEmbedProps): Element;
```
### Parameters
Props of type [PayEmbedProps](https://portal.thirdweb.com/references/typescript/v5/PayEmbedProps) to configure the PayEmbed component.
#### Type
```ts
let props: {
className?: string;
client: ThirdwebClient;
connectOptions?: PayEmbedConnectOptions;
hiddenWallets?: Array;
locale?: LocaleId;
payOptions?: PayUIOptions;
style?: React.CSSProperties;
supportedTokens?: SupportedTokens;
theme?: "light" | "dark" | Theme;
};
```
### Returns
```ts
let returnType: Element;
```
---
**React Hooks**
---
# Extensions
---
## EIP5792
---
## useCallsStatus
A hook to get a call bundle's current status according to [ EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) .
This function is dependent on the wallet's support for EIP-5792 and could throw an error if it's not supported.
### Example
```tsx
import { useCallsStatus } from "thirdweb/react";
const { data: status, isLoading } = useCallsStatus({
bundleId,
client,
});
```
```ts
function useCallsStatus(options: {
bundleId: string;
client: ThirdwebClient;
queryOptions?: { enabled?: boolean; retry?: number };
}): UseQueryResult;
```
### Parameters
#### Type
```ts
let options: {
bundleId: string;
client: ThirdwebClient;
queryOptions?: { enabled?: boolean; retry?: number };
};
```
### Returns
```ts
let returnType: UseQueryResult;
```
a React Query object.
---
## useCapabilities
A hook to get the current wallet's capabilities according to [ EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) .
This function is dependent on the wallet's support for EIP-5792, but will not throw. _The returned object contains a `message` field detailing any issues with the wallet's support for EIP-5792._
### Example
```tsx
import { useCapabilities } from "thirdweb/react";
const { data: capabilities, isLoading } = useCapabilities();
```
```ts
function useCapabilities(options?: {
queryOptions?: { enabled?: boolean; retry?: number };
}): UseQueryResult;
```
### Parameters
#### Type
```ts
let options: { queryOptions?: { enabled?: boolean; retry?: number } };
```
### Returns
```ts
let returnType: UseQueryResult;
```
a React Query object.
---
## useSendCalls
A hook to send [ EIP-5792](https://eips.ethereum.org/EIPS/eip-5792) calls to a wallet. This hook works with all Thirdweb wallets (in-app and smart) and certain injected wallets that already support EIP-5792\. Transactions will be bundled and sponsored when those capabilities are supported, otherwise they will be sent as individual transactions.
When calls are sent, all contracts that are interacted with will have their corresponding reads revalidated via React Query.
This hook is dependent on the wallet's support for EIP-5792 and could fail. The mutatuon function will use your currently connected wallet by default, but you can pass it a specific wallet to use if you'd like.
### Example
```tsx
import { useSendCalls } from "thirdweb/react";
const sendTx1 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x33d9B8BEfE81027E2C859EDc84F5636cbb202Ed6",
});
const sendTx2 = approve({
contract: USDT_CONTRACT,
amount: 100,
spender: "0x2a4f24F935Eb178e3e7BA9B53A5Ee6d8407C0709",
});
const { mutate: sendCalls, data: bundleId } = useSendCalls({
client,
});
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});
```
Await the bundle's full confirmation:
```tsx
const { mutate: sendCalls, data: bundleId } = useSendCalls({
client,
waitForResult: true,
});
await sendCalls({
wallet,
client,
calls: [sendTx1, sendTx2],
});
```
Sponsor transactions with a paymaster:
```ts
const { mutate: sendCalls, data: bundleId } = useSendCalls();
await sendCalls({
client,
calls: [sendTx1, sendTx2],
capabilities: {
paymasterService: {
url: `https://${CHAIN.id}.bundler.thirdweb.com/${client.clientId}`,
},
},
});
```
We recommend proxying any paymaster calls via an API route you setup and control.
```ts
function useSendCalls(__namedParameters: {
client: ThirdwebClient;
waitForResult?: boolean;
}): UseMutationResult<
GetCallsStatusResponse | WalletSendCallsId,
Error,
Omit & { wallet?: Wallet }
>;
```
### Parameters
#### Type
```ts
let __namedParameters: {
client: ThirdwebClient;
waitForResult?: boolean;
};
```
### Returns
```ts
let returnType: UseMutationResult<
GetCallsStatusResponse | WalletSendCallsId,
Error,
Omit & { wallet?: Wallet }
>;
```
A React Query mutatuon object to interact with sendCalls
---
## ENS
---
## useEnsAvatar
Get the ENS avatar for an ENS name
### Example
```tsx
import { useEnsAvatar } from "thirdweb/react";
const { data: ensAvatar } = useEnsAvatar({
client,
ensName: "my-ens-name.eth",
});
```
```ts
function useEnsAvatar(options: {
client: ThirdwebClient;
ensName: undefined | null | string;
}): UseQueryResult;
```
### Parameters
the client and ENS name to get the avatar for
#### Type
```ts
let options: {
client: ThirdwebClient;
ensName: undefined | null | string;
};
```
### Returns
```ts
let returnType: UseQueryResult;
```
* a query object that resolves to the avatar
---
## useEnsName
Get the ENS name and avatar for an address
### Example
```tsx
import { useEnsName } from "thirdweb/react";
const { data: ensName } = useEnsName({
client,
address: "0x1234...",
});
```
```ts
function useEnsName(options: {
address: undefined | string;
client: ThirdwebClient;
}): UseQueryResult;
```
### Parameters
the client and address to get the ENS name and avatar for
#### Type
```ts
let options: { address: undefined | string; client: ThirdwebClient };
```
### Returns
```ts
let returnType: UseQueryResult