Integration
Integrating ton-connect enhances user interactions with the TON blockchain in your DApp. Below are the steps for integrating ton-connect using React, Vue, and HTML/JavaScript (Vanilla).
Frontend Integration with ton-connect
1. React Integration
Installation
To integrate TON Connect into your React application, install the @tonconnect/ui-react package:
npm install @tonconnect/ui-reactTON Connect Initiation
Wrap your application with TonConnectUIProvider, passing the manifest URL:
import { TonConnectUIProvider } from '@tonconnect/ui-react';
export function App() {
return (
<TonConnectUIProvider manifestUrl="https://<YOUR_APP_URL>/tonconnect-manifest.json">
{ /* Your app */ }
</TonConnectUIProvider>
);
}Connect to the Wallet
Add the TonConnectButton to allow users to connect their wallets:
2. Vue Integration
Installation
To start integrating TON Connect into your Vue application, install the @townsquarelabs/ui-vue package:
TON Connect Initiation
Wrap your application with TonConnectUIProvider, specifying the manifest URL in the options:
Connect to the Wallet
Use the TonConnectButton to enable wallet connections:
3. HTML/JavaScript (Vanilla) Integration
Installation
To integrate TON Connect into your HTML/JavaScript application, add the script in the <head> of your HTML:
TON Connect Initiation
Add a button in your HTML to connect to the wallet:
Connect to the Wallet
The "Connect" button will automatically handle clicks. You can also open the connect modal programmatically:
Last updated
Was this helpful?