A sleek, responsive URL shortener built with vanilla JavaScript and the Bitly API. Features a modern glassmorphism design, dark mode support, and comprehensive error handling.
- Glassmorphism UI with backdrop blur effects
- Gradient backgrounds and smooth animations
- Responsive design that works on all devices
- Dark/Light mode toggle with system preference detection
- Font Awesome icons for professional appearance
- Real Bitly API integration for reliable short links
- Real-time URL validation with visual feedback
- Duplicate detection to prevent unnecessary API calls
- Comprehensive error handling for various scenarios
- One-click copy with visual confirmation
- Keyboard shortcuts for power users
- Auto-focus input field for quick access
- Loading states with animated spinners
- Emoji-enhanced feedback messages
Enter- Shorten URLEscape- Clear input and resultsCtrl/Cmd + Shift + D- Toggle dark mode
- Frontend: Vanilla JavaScript (ES6+), HTML5, CSS3
- API: Bitly REST API v4
- Icons: Font Awesome 6.4.0
- Storage: localStorage for theme persistence
- Design: CSS Grid, Flexbox, CSS Custom Properties
- A modern web browser (Chrome 60+, Firefox 55+, Safari 12+)
- Bitly API access token
-
Clone the repository
git clone https://github.com/akashasahu07/URL-Shortener.git cd url-shortener -
Get your Bitly API token
- Sign up at Bitly.com
- Go to Settings β Developer Settings
- Generate a new access token
-
Configure the API token
// Replace the token in the JavaScript section const ACCESS_TOKEN = "your_bitly_token_here";
-
Launch the application
- Open
index.htmlin your browser - Or serve it with a local server:
# Using Python python -m http.server 8000 # Using Node.js npx serve . # Using PHP php -S localhost:8000
- Open
- Mobile: < 640px (Single column, full-width buttons)
- Tablet: 641px - 1024px (Optimized spacing)
- Desktop: > 1025px (Maximum container width)
- Primary:
#667eeaβ#764ba2(Gradient) - Background:
#667eeaβ#764ba2 - Container:
rgba(255, 255, 255, 0.95) - Text:
#1e293b
- Primary:
#818cf8β#c084fc(Gradient) - Background:
#0f0f23β#1a1a2eβ#16213e - Container:
rgba(15, 52, 96, 0.85) - Text:
#e2e8f0
const ACCESS_TOKEN = "your_bitly_token"; // Replace with your token
const API_URL = "https://api-ssl.bitly.com/v4/shorten"; // Bitly endpoint// Theme persistence
localStorage.setItem('darkMode', 'enabled'); // or 'disabled'// Adjust message display time (milliseconds)
setTimeout(() => {
messageDiv.textContent = '';
}, 5000); // 5 seconds| Browser | Version | Support |
|---|---|---|
| Chrome | 60+ | β Full |
| Firefox | 55+ | β Full |
| Safari | 12+ | β Full |
| Edge | 79+ | β Full |
| Opera | 47+ | β Full |
// β οΈ Current implementation (development only)
const ACCESS_TOKEN = "your_token_here";
// β
Recommended for production
// Use environment variables or backend proxy
fetch('/api/shorten', {
method: 'POST',
body: JSON.stringify({ url: longURL })
});- URL format validation using
new URL() - Input sanitization with
trim() - HTTPS/HTTP protocol verification
- Modern CSS: Hardware-accelerated animations
- Efficient API calls: Prevents duplicate requests
- Optimized images: SVG icons and CSS gradients
- Minimal dependencies: No external JavaScript libraries
/* Custom gradient example */
body {
background: linear-gradient(135deg, #your-color1 0%, #your-color2 100%);
}/* Adjust transition duration */
.btn {
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}.container {
max-width: min(90vw, 520px); /* Adjust max width */
}| Plan | Requests/Hour | Requests/Month |
|---|---|---|
| Free | 1,000 | 1,000 |
| Basic | 10,000 | 10,000 |
| Premium | 100,000 | 100,000 |
The application handles various error scenarios:
- 400: Invalid URL format
- 401: Invalid/expired API token
- 403: Insufficient permissions
- 429: Rate limit exceeded
- 500: Bitly server error
- Network: Connection issues
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow ES6+ standards
- Use semantic HTML5
- Maintain responsive design
- Add appropriate comments
- Test across multiple browsers
This project is licensed under the MIT License - see the LICENSE file for details.
- Bitly API for URL shortening service
- Font Awesome for beautiful icons
- Inter Font for modern typography
- CSS-Tricks for glassmorphism inspiration
If you have any questions or need help, please:
- Check the Issues page
- Create a new issue with detailed description
- Contact: your.email@example.com
Made with β€οΈ using modern web technologies
β Star this repo if you found it helpful!