A pure React implementation of the Dead Man's Switch dApp, converted from the original Next.js version. This decentralized application allows users to create time-locked encrypted secrets that automatically reveal if they fail to reset the timer within a specified interval.
- Node.js 18+
- NPM or Yarn
- A Solana wallet (Phantom or Solflare recommended)
- Clone and navigate to the React app:
cd react-app
npm install
- Set up environment variables:
cp .env.example .env.local
Edit .env.local
with your configuration:
VITE_SOLANA_NETWORK=devnet
VITE_SOLANA_RPC_URL=https://api.devnet.solana.com
VITE_PROGRAM_ID=f9kTeCnUyNX3Pg43d7DtjNixVYHLBynCY5ukfXDXcrs
VITE_LIT_NETWORK=datil-dev
- Start the development server:
npm run dev
- Open your browser:
Navigate to
http://localhost:3000
react-app/
βββ src/
β βββ components/ # React components
β β βββ WalletProvider.tsx
β β βββ ErrorBoundary.tsx
β β βββ Layout.tsx
β β βββ Sidebar.tsx
β β βββ WalletButton.tsx
β β βββ NetworkStatus.tsx
β βββ pages/ # Page components
β β βββ HomePage.tsx
β β βββ CreatePage.tsx
β β βββ MyLocksPage.tsx
β β βββ PublicUnlocksPage.tsx
β β βββ HelpPage.tsx
β β βββ AboutPage.tsx
β βββ hooks/ # Custom React hooks
β β βββ useWalletAuth.ts
β β βββ useProgram.ts
β β βββ useLitProtocol.ts
β β βββ useIpfs.ts
β β βββ useNetworkStats.ts
β β βββ useUserSwitches.ts
β βββ lib/ # Utility libraries
β β βββ env-validation.ts
β β βββ time-utils.ts
β β βββ rate-limit.ts
β β βββ retry-utils.ts
β β βββ wallet-utils.ts
β βββ types/ # TypeScript type definitions
β βββ App.tsx # Main app component
β βββ main.tsx # React entry point
β βββ index.css # Global styles
β βββ idl.json # Anchor program IDL
βββ public/ # Static assets
βββ package.json # Dependencies and scripts
βββ vite.config.ts # Vite configuration
βββ tailwind.config.js # Tailwind CSS configuration
βββ tsconfig.json # TypeScript configuration
- Next.js: File-based routing with
app/
directory - React: React Router DOM with route definitions in
App.tsx
- Next.js:
NEXT_PUBLIC_*
prefix - React:
VITE_*
prefix for Vite
- Next.js: Built-in webpack configuration
- React: Vite with custom configuration for Solana/crypto polyfills
- Next.js: Server-side rendering and static generation
- React: Client-side rendering only
- Next.js:
next/dynamic
for code splitting - React: React lazy loading and standard dynamic imports
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build
npm run preview
# Run TypeScript checks
npm run lint
# Solana/Anchor commands (run from parent directory)
npm run anchor:build # Build Anchor program
npm run anchor:deploy # Deploy to devnet
npm run anchor:test # Run tests
npm run check:deployment # Verify deployment
VITE_PROGRAM_ID=f9kTeCnUyNX3Pg43d7DtjNixVYHLBynCY5ukfXDXcrs
VITE_SOLANA_NETWORK=devnet # mainnet-beta, testnet, devnet
VITE_SOLANA_RPC_URL=https://api.devnet.solana.com
VITE_LIT_NETWORK=datil-dev # datil-dev, datil-test
The app includes polyfills for Node.js modules to work in browsers:
crypto
βcrypto-browserify
stream
βstream-browserify
buffer
βbuffer
process
βprocess/browser
- Basic React app structure
- Vite configuration with Solana polyfills
- Environment variable setup
- Component architecture
- Routing with React Router
- Wallet integration (WalletProvider, WalletButton)
- Layout and navigation (Sidebar, Layout)
- Error boundaries
- TypeScript configuration
- Tailwind CSS styling
- Hooks migration (core utilities)
- Core components migration
- SwitchCreator component
- SwitchDashboard component
- PublicUnlocksClient component
- RevealedSecrets component
- InputValidation component
- LoadingSpinner component
- API routes migration (currently in Next.js
/api
directory) - IPFS integration testing
- Lit Protocol integration testing
- Complete component testing
- Production deployment setup
- Performance optimization
-
Component Migration:
- Remove
'use client'
directives - Replace
next/link
withreact-router-dom
- Update
useRouter
withuseNavigate
anduseLocation
- Replace
process.env.NEXT_PUBLIC_*
withimport.meta.env.VITE_*
- Remove
-
API Routes:
- Current API routes in
/api
directory need to be migrated to a separate backend - Or adapted to work with Vite's dev server proxy
- Current API routes in
-
Dynamic Imports:
- Replace
next/dynamic
with React'slazy()
andSuspense
- Replace
Next.js:
'use client';
import Link from 'next/link';
import { useRouter } from 'next/navigation';
const network = process.env.NEXT_PUBLIC_SOLANA_NETWORK;
React:
import { Link, useNavigate } from 'react-router-dom';
const network = import.meta.env.VITE_SOLANA_NETWORK;
const navigate = useNavigate();
npm run dev
npm run build
npm run preview
The built app is a static site that can be deployed to:
- Vercel
- Netlify
- GitHub Pages
- AWS S3 + CloudFront
- Any static hosting service
- Original Next.js Version:
../
(parent directory) - Solana Program:
../solana/
- Deployment Scripts:
../scripts/
-
Experimental: This is a migration in progress. Not all features are complete.
-
Testnet Only: Currently configured for Solana devnet. Don't use real funds.
-
API Dependencies: Some features depend on API routes that are still in the Next.js version.
-
Security: Always verify transactions and never share private keys.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - see the main project's LICENSE file for details.
Note: This React version is actively being developed. Check the Next.js version in the parent directory for the most complete implementation.