A modern web application that allows users to upload images and automatically remove backgrounds using the remove.bg API. Built with React 19.1.1, TypeScript 5.8.3, and Tailwind CSS 4.1.13 for a seamless user experience.
- Drag & Drop Upload: Intuitive interface for image upload
- AI-Powered Processing: Automatic background removal using remove.bg API
- Multiple Formats: Support for JPEG, PNG, and WEBP images
- Real-time Preview: Instant preview of uploaded and processed images
- Before/After Comparison: Side-by-side comparison view
- Download Ready: One-click download of processed images
- Responsive Design: Works perfectly on desktop and mobile devices
- Error Handling: Comprehensive error handling with user-friendly messages
- Node.js 18+ installed on your system
- A remove.bg API key (get one free at remove.bg)
- Basic understanding of environment variables
-
Install dependencies
npm install
-
Configure environment variables Create a
.envfile in the root directory:VITE_REMOVE_BG_API_KEY=your_api_key_here
-
Start the development server
npm run dev
-
Open your browser Navigate to
http://localhost:5173
-
Get your API key:
- Visit remove.bg API
- Sign up for a free account
- Get your API key from the dashboard
-
Configure the API key:
- Create a
.envfile in the project root directory - Add your API key:
VITE_REMOVE_BG_API_KEY=your_actual_api_key - The API key will be securely integrated into the application
- Never commit the
.envfile to version control
- Create a
-
Upload an Image:
- Drag and drop an image onto the upload area, or
- Click to browse and select an image file
- Supported formats: JPEG, PNG, WEBP (max 12MB)
-
Process the Image:
- Click "Remove Background" to start processing (API key is pre-configured)
- Wait for the AI to process your image
-
Download Result:
- View the processed image with transparent background
- Use the comparison view to see before/after
- Click "Download" to save the result
- Frontend: React 19.1.1 with TypeScript 5.8.3
- Build Tool: Vite 7.1.2
- Styling: Tailwind CSS 4.1.13
- State Management: React Context API with useReducer
- File Handling: react-dropzone 14.3.8
- Icons: Lucide React 0.544.0
- API Integration: remove.bg REST API
src/
├── components/ # React components
│ ├── Header.tsx # App header with API key input
│ ├── Footer.tsx # App footer
│ ├── ImageUploader.tsx # Drag & drop upload component
│ ├── ImageProcessor.tsx # Processing control component
│ ├── ImageGallery.tsx # Results display component
│ └── ErrorAlert.tsx # Error handling component
├── context/
│ └── AppContext.tsx # Global state management
├── services/
│ └── backgroundRemovalService.ts # API integration
├── types/
│ └── index.ts # TypeScript type definitions
├── assets/ # Static assets
├── App.css # Global styles
├── App.tsx # Main app component
├── index.css # Base styles
├── main.tsx # App entry point
└── vite-env.d.ts # Vite type definitions
- State Management: Uses React Context with useReducer for predictable state updates
- File Validation: Client-side validation for file type and size (JPEG, PNG, WEBP, max 12MB)
- Error Handling: Comprehensive error categorization and user feedback with ErrorAlert component
- Progress Tracking: Real-time progress updates during processing with visual indicators
- Memory Management: Proper cleanup of object URLs to prevent memory leaks
- Responsive Design: Mobile-first design with Tailwind CSS utilities
- Modern UI: Glass-morphism effects and smooth animations for enhanced user experience
The application supports various remove.bg API options:
- Output Size: Auto, Preview (0.25 MP), or Full Resolution
- Output Format: PNG (transparent) or JPG (white background)
- Subject Type: Auto-detect, Person, or Product
The application requires the following environment variables:
VITE_REMOVE_BG_API_KEY: Your remove.bg API key (required for background removal functionality)
Create a .env file in the project root:
VITE_REMOVE_BG_API_KEY=your_api_key_hereSecurity Note: Never commit your .env file to version control. Add .env to your .gitignore file.
- TypeScript: Strict mode enabled with comprehensive type checking
- ESLint: Configured with React and TypeScript rules
- Vite: Optimized for fast development and production builds
- PostCSS: Integrated with Tailwind CSS for utility-first styling
- Environment Variables: Vite automatically loads
.envfiles withVITE_prefix
Ensure your .gitignore includes:
# Environment variables
.env
.env.local
.env.*.local
# Dependencies
node_modules/
# Build output
dist/
# Build the application
npm run build
# Preview the build locally
npm run previewThe built files will be in the dist directory, ready for deployment to any static hosting service.
- Chrome 90+
- Firefox 88+
- Safari 14+
- Edge 90+
Note: Modern browsers with ES2020+ support required for optimal performance.
- No Server Storage: Images are processed directly through the remove.bg API
- Environment-based API Key: API keys are securely stored in environment variables, not exposed in the client
- No Data Tracking: No user data is collected or tracked
- Secure Processing: All processing happens via HTTPS
- Client-side Processing: No server-side storage or processing of images
-
"Invalid API Key" Error
- Verify your API key is correct in the
.envfile - Ensure the environment variable name is exactly
VITE_REMOVE_BG_API_KEY - Restart the development server after modifying the
.envfile - Check that you have remaining credits on your remove.bg account
- Verify your API key is correct in the
-
"File Too Large" Error
- Ensure your image is under 12MB
- Consider resizing the image before upload
-
"Network Error"
- Check your internet connection
- Try again after a few moments
-
Processing Fails
- Ensure the image is a valid format (JPEG, PNG, WEBP)
- Try with a different image
- Check your remove.bg account credits
- Check the browser console for detailed error messages
- Verify your remove.bg API key in the
.envfile - Ensure the
.envfile is in the project root directory - Restart the development server after changing environment variables
- Verify your remove.bg account status and remaining credits
- Ensure you have a stable internet connection
This project is open source and available under the MIT License.
- remove.bg for the powerful background removal API
- React for the amazing framework
- Tailwind CSS for the utility-first CSS framework
- Lucide for the beautiful icons