React + Vite + TypeScript frontend for the Lockr secret sharing application.
- React 18 - UI library
- Vite - Build tool and dev server
- TypeScript - Type safety
- Tailwind CSS - Styling
- React Router - Client-side routing
- Axios - HTTP client
- react-hot-toast - Toast notifications
- lucide-react - Icons
- Node.js 20 (use
nvm use 20) - Backend server running on port 4000
-
Install dependencies:
npm install
-
Create environment file:
cp .env.example .env
-
Configure
.env:VITE_API_BASE_URL=http://localhost:4000
Development:
npm run devRuns on http://localhost:5173
Production build:
npm run build
npm run previewfrontend/
├── src/
│ ├── components/ # Reusable UI components
│ │ ├── Button.tsx
│ │ ├── Card.tsx
│ │ └── Layout.tsx
│ ├── lib/ # Utilities and API client
│ │ ├── api.ts # Axios instance
│ │ └── secrets.ts # API functions
│ ├── pages/ # Route pages
│ │ ├── CreateSecret.tsx
│ │ ├── Success.tsx
│ │ ├── ViewSecret.tsx
│ │ └── Burned.tsx
│ ├── types/ # TypeScript types
│ │ └── index.ts
│ ├── App.tsx # Router setup
│ ├── main.tsx # Entry point
│ └── index.css # Global styles
├── public/ # Static assets
├── index.html # HTML template
├── vite.config.ts # Vite configuration
├── tailwind.config.js # Tailwind configuration
└── package.json
| Route | Component | Description |
|---|---|---|
/ |
CreateSecret | Create a new secret with expiry and view limit |
/success |
Success | Display shareable link after creation |
/s/:token |
ViewSecret | View and decrypt a secret (one-time) |
/burned |
Burned | Shown when secret is expired/burned |
- Textarea for secret input (1-10,000 characters)
- Expiry dropdown: 5 mins, 30 mins, 1 hour, No expiry
- Max views input (1-100, default 1)
- Form validation
- Loading states
- Toast notifications
- Display shareable link
- Copy to clipboard button
- Secret metadata (expiry, max views)
- Warning about one-time use
- Create another secret button
- Test link button
- Automatic secret retrieval on mount
- Display decrypted secret
- Copy secret button
- Warning about remaining views
- Handles 404 (redirects to /burned)
- Network error handling with retry
- Informative message about burned/expired secrets
- Explanation of why secret might be unavailable
- Create new secret button
- Header with logo and navigation
- Consistent page structure
- Footer with security info
- Multiple variants: primary, secondary, outline
- Loading state with spinner
- Disabled state
- Full width option
- Clean white card with shadow
- Consistent padding and borders
- Base URL from environment variable
- Request/response interceptors
- Error logging
createSecret(data)- POST /api/secretsgetSecret(token)- GET /api/secrets/:token
- Custom color palette (primary blue)
- Responsive design
- Utility-first approach
- Custom components
- Clean, minimal interface
- Gradient backgrounds
- Card-based layouts
- Consistent spacing and typography
- Accessible focus states
- Validation errors - Display Zod error messages
- 404 errors - Redirect to /burned page
- Network errors - Show retry option with toast
- Generic errors - User-friendly error messages
- ✅ Disabled submit while loading
- ✅ Form validation with helpful messages
- ✅ Toast notifications for all actions
- ✅ Copy to clipboard with visual feedback
- ✅ Loading spinners
- ✅ Responsive design
- ✅ Keyboard accessible
- ✅ Clear call-to-actions
| Variable | Description | Default |
|---|---|---|
VITE_API_BASE_URL |
Backend API URL | http://localhost:4000 |
- Hot Reload: Vite provides instant hot module replacement
- TypeScript: Use strict mode for better type safety
- Tailwind: Use the Tailwind CSS IntelliSense extension
- Icons: Browse lucide-react icons at https://lucide.dev
# Build
npm run build
# Preview build locally
npm run previewBuild output goes to dist/ directory.
- Modern browsers (Chrome, Firefox, Safari, Edge)
- ES2020+ features
- CSS Grid and Flexbox
MIT