30th July 2025
3 min read
Transak is a fiat-to-crypto on-ramp solution that allows users to buy and sell cryptocurrencies directly within their application. It offers support for multiple payment options, including bank transfers, credit/debit cards, and Apple Pay. For more about crypto, visit crypto development services.
Before we begin, ensure you have:
Also, Read | Creating a Custom Hyperliquid Dashboard: Track Live Holdings in React
Vite is a modern and lightning-fast build tool designed for React applications. Let's create a new project:
npm create vite@latest transak-vite-app --template react
cd transak-vite-app
npm install
npm run dev
This will start your app at http://localhost:5173.
npm install @transak/transak-sdk
Transak provides a JavaScript SDK that can be embedded in your React app.
import Transak from '@transak/transak-sdk';
Create a styled button that triggers the Transak widget:
The handleTransak function initializes the widget:
const handleTransak = () => {
try {
const transak = new Transak({
apiKey: TRANSAK_API_KEY, // Your Transak API key
environment: STAGING, // or 'PRODUCTION'
productsAvailed: 'SELL', // 🟢 This enables OFF-RAMP
hideExchangeScreen: true,
themeColor: '000000',
hostURL: window.location.origin,
widgetHeight: '600px',
widgetWidth: '450px',
});
transak.init();
Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, async (orderData) => {
console.log(orderData, "Order data");
});
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
transak.close();
transak.logoutUser();
transak.cleanup();
});
Transak.on('*', (data) => {
console.log('📦 Transak Event', data);
});
} catch (err) {
console.log(err, 'transak error.');
}
};
You may also like | Build a Crypto Payment Gateway Using Solana Pay and React
import { Transak } from '@transak/transak-sdk';
const TransakButton = () => {
const handleTransak = () => {
try {
const transak = new Transak({
apiKey: TRANSAK_API_KEY, // Your Transak API key
environment: STAGING, // or 'PRODUCTION'
productsAvailed: 'SELL', // 🟢 This enables OFF-RAMP
hideExchangeScreen: true,
themeColor: '000000',
hostURL: window.location.origin,
widgetHeight: '600px',
widgetWidth: '450px',
});
transak.init();
Transak.on(Transak.EVENTS.TRANSAK_ORDER_SUCCESSFUL, async (orderData) => {
console.log(orderData, 'Order data');
});
Transak.on(Transak.EVENTS.TRANSAK_WIDGET_CLOSE, () => {
transak.close();
transak.logoutUser();
transak.cleanup();
});
Transak.on('*', (data) => {
console.log('📦 Transak Event', data);
});
} catch (err) {
console.log(err, 'transak error.');
}
};
return (
);
};
export default TransakButton;
Also, Discover | Developing a Cross-Platform Crypto Wallet with Web3.js & React
This implementation provides:
Next Steps:
For advanced features, refer to Transak's Official Documentation.
OUTPUT
If you are planning to get into the blockchain or web3 space, connect with our skilled blockchain developers to bring your vision into reality.