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.localEdit .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/dynamicfor 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 deploymentVITE_PROGRAM_ID=f9kTeCnUyNX3Pg43d7DtjNixVYHLBynCY5ukfXDXcrsVITE_SOLANA_NETWORK=devnet # mainnet-beta, testnet, devnet
VITE_SOLANA_RPC_URL=https://api.devnet.solana.com
VITE_LIT_NETWORK=datil-dev # datil-dev, datil-testThe app includes polyfills for Node.js modules to work in browsers:
crypto→crypto-browserifystream→stream-browserifybuffer→bufferprocess→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
/apidirectory) - IPFS integration testing
- Lit Protocol integration testing
- Complete component testing
- Production deployment setup
- Performance optimization
-
Component Migration:
- Remove
'use client'directives - Replace
next/linkwithreact-router-dom - Update
useRouterwithuseNavigateanduseLocation - Replace
process.env.NEXT_PUBLIC_*withimport.meta.env.VITE_*
- Remove
-
API Routes:
- Current API routes in
/apidirectory 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/dynamicwith 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 devnpm run build
npm run previewThe 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.