React Integration Guide
This guide walks you through creating a casino application using BetSwirlโs React UI library.
What youโll build: A fully functional multi-game with multi-chain support, custom theming, and background image - exactly like our live demoย .
Time: ~10 minutes
Prerequisites
- Node.js v18+
- Git
- GitHub account
- Vercel account
Build Your Casino App
Fork Repository
Step 1: Fork Repository
Fork this repository: https://github.com/BetSwirl/ui-react-demoย
Click the โForkโ button in the top right corner to create your own copy.
Step 2: Clone and Run
# Clone your forked repository
git clone https://github.com/YOUR_USERNAME/ui-react-demo.git
cd ui-react-demo
# Install dependencies
npm install
# Create .env file from template
cp .env.example .envYou can fill .env now or leave it empty - how to configure affiliate address and custom RPC is explained below in Add your affiliate address & custom RPCs section.
# Start dev server (your .env file must be empty or configured to make it working)
npm run devOpen in browser http://localhost:5173
What You Have Now
Your React casino application is ready with the following features already configured:
- BetSwirl SDK integration with support for Base, Polygon, Arbitrum, BSC and Avalanche
- OnchainKit wallet connection
- Multiple games with navigation (Dice, Coin Toss, Roulette)
- Custom theming and branding with gold accents and dark theme
- Background images for page and game
- Freebet system for user promotions
- Leaderboard support for competitive tournaments
- Token selection with filtering for ETH, BETS, DEGEN and USDC
Next steps: Deploy to Vercel and add your affiliate address to start earning 30% commission from all bets.
Deploy to Vercel
Now deploy your casino to the web and get a public URL.
1. Sign up on Vercel: Go to vercel.comย โ โSign Upโ โ โContinue with GitHubโ โ Authorize access
2. Create new project: Click โAdd Newโฆโ โ โProjectโ โ Find my-casino-app โ โImportโ
3. Configure and deploy: Vercel auto-detects Vite settings. Leave defaults and click โDeployโ
4. Wait for build to complete (1-2 minutes), then copy your production URL: https://my-casino-app.vercel.app
5. Test your live casino: Open the URL, connect wallet, and place a bet.
Whatโs next: Every git push automatically deploys. GitHub now shows a โDeploymentsโ tab with deployment history and status checks.
Add your affiliate address & custom RPCs
As an affiliate, you earn 30% of house edge revenue from every bet placed through your casino. Add your wallet address to start earning, and configure custom RPC endpoints for better performance.
Learn more: Affiliate Program - track earnings, create freebets, manage leaderboards, and claim revenue.
1. Add environment variables to Vercel:
- Go to your project on vercel.comย
- Click โSettingsโ โ โEnvironment Variablesโ
- Add your affiliate address (required):
| Name | Value |
|---|---|
VITE_AFFILIATE_ADDRESS | Your wallet address (to earn 30% commission) |
- Optional: Add custom RPC endpoints for better performance and reliability. Without these, the app uses free public RPCs which may be slower or rate-limited:
| Name | Value |
|---|---|
VITE_BASE_RPC_URL | Your Base RPC URL |
VITE_POLYGON_RPC_URL | Your Polygon RPC URL |
VITE_ARBITRUM_RPC_URL | Your Arbitrum RPC URL |
VITE_BSC_RPC_URL | Your BSC RPC URL |
VITE_AVALANCHE_RPC_URL | Your Avalanche RPC URL |
RPC providers: Alchemyย , Infuraย , QuickNodeย (most offer free tiers)
- Optional: Enable test mode (for testing on testnet chains):
| Name | Value |
|---|---|
VITE_TEST_MODE | true or false |
Click โSaveโ after adding variables.
2. Deploy changes:
Once you saved the new environment variables, Vercel will automatically ask you to redeploy the project.
3. Check your earnings:
Once deployed, track your affiliate revenue:
- Go to Revenues Dashboardย
- Connect the same wallet you used for
VITE_AFFILIATE_ADDRESS - View your earnings in real-time (30% of house edge from each bet)
- Click โClaimโ to withdraw your earnings
Optional Enhancements
The base setup above gives you a fully functional casino. Below are optional features you can add to enhance your application.
- How to Add Multiple Games - Switch between Dice, CoinToss, Roulette and more
- How to Add a Chain - Add or change supported blockchain networks
- How to Check Available Tokens - Check which tokens are available for betting
- BetSwirlSDKProvider Configuration Reference - All BetSwirlSDKProvider parameters, Leaderboard Integration, Custom Branding
โ
Example Result
- Demo Github repository: github.com/BetSwirl/betswirl-ui-react-demoย
- Live Demo: ui-react-demo.betswirl.comย
- StoryBook: ui-react-storybook.betswirl.comย