Integration
React
1
Install necessary libraries
Install the That is enough for the most basic usage. However, to allow for more complex examples, install the following packages as well:
@tonconnect/ui-react package:2
Create a TON Connect manifest
TON Connect manifest is a small JSON file that lets wallets discover information about your dApp. It should be named Here’s an example of such a file:After creating the manifest file, import See more detailed information here: TON Connect manifest.
tonconnect-manifest.json, placed at https://<YOUR_APP_URL>/tonconnect-manifest.json, and be accessible with a direct GET request.Notice that CORS should be disabled, and there should be no authorization or intermediate proxies like CloudFlare or similar services. The connection also won’t work when using a VPN.
tonconnect-manifest.json
TonConnectUIProvider to the root of your dApp and pass the manifest URL:3
Add a button in the UI
Users need a clear way of connecting their wallets to your app, so you must give a clear UI element to do so. Usually, that is a Connect wallet button.Some in-wallet browsers automatically open a wallet connection modal when your dApp loads. Still, always provide a button alternative in case the user dismissed the modal window or wants to connect a wallet after doing their research.Adding The
TonConnectButton is straightforward:TonConnectButton is a universal UI component for initializing a connection. After the wallet is connected, it transforms into a wallet menu. Prefer to place the Connect wallet button in the top right corner of your app.You can add the className and style props to the button:You cannot pass a child element to the
TonConnectButton.4
Utilize TON Connect in your dApp
Manual connection initiation
You can always initiate the connection manually using theuseTonConnectUI hook and openModal method.
openSingleWalletModal() method. It takes the wallet’s app_name and opens the corresponding wallet modal, returning a promise that resolves once the modal window opens.
To find the correct app_name of the target wallet, refer to the wallets-list.json file.
UI customization
To customize the UI of the modal, use thetonConnectUI object provided by the useTonConnectUI() hook, and then assign designated values as an object to the uiOptions property.
Note that you have to pass an object and never set individual sub-properties under
uiOptions. That is, DO NOT do this:uiOptions in the external reference: TonConnectUiOptions Interface.
Minimal React setup
Putting all the above together, here’s a most minimal React dApp integration example. First, start by creating a new project with React and Vite:@tonconnect/ui-react dependency:
App.tsx to have the following imports present:
src/App.tsx
App.tsx file, replace your App() function with the following:
src/App.tsx
npm run dev to launch and preview your app in the browser at http://localhost:5173. All changes in code will be reflected live.
Connect a wallet and try using the Send 0.1 TON button. Notice that the exact sum of Toncoin shown in your wallet will be different, because there are certain fees required for such a transfer by the blockchain itself.
When building apps, make sure to always take fees into consideration and show them to the end-user.
This example sends real TON from the connected wallet. Try it with a testnet wallet first or send less Toncoin, e.g., 0.001 TON instead of 1 TON, to avoid surprises.
Next.js
TonConnectUIProvider relies on browser APIs and should be rendered only on the client side, i.e., on the frontend. As such, in a Next.js application, you should mark the component that wraps the provider with 'use client' directive.
Alternatively, dynamically import the provider to disable server-side rendering.
Both approaches ensure that the provider is invoked only in the browser and works correctly there.
Example for the app router:
app/providers.tsx
pages router, you can dynamically import the provider:
Vanilla JS
For quick testing, use the following single-file HTML example.This example sends real Toncoin from the connected wallet. Try it with a testnet wallet first or send less Toncoin, e.g., 0.001 TON instead of 1, to avoid surprises.
index.html
Usage
Once the app is integrated, follow one of these common usage recipes:- Send Toncoin
- Send USDT
- Send a Jetton
- Send an NFT
- Check Toncoin balance
- Check USDT balance
- Check Jetton balance
- Check NFT items present
- Track a transaction and confirm its status
- Make a sign data request and verify signed data
- Make a proof request and verify it