A beautiful, responsive photo gallery built with React.js that fetches stunning images from the Unsplash API. Features search functionality, quick tags, and elegant hover effects.
- ๐ผ๏ธ Image Gallery: Display 10 random high-quality images from Unsplash
- ๐ Search Functionality: Search for specific photos using keywords
- ๐ท๏ธ Quick Search Tags: Pre-defined tags for popular searches (cars, flowers, boats, nature, cats, architecture)
- ๐จโ๐จ Photo Credits: Display photographer names with links to their Unsplash profiles
- ๐ฑ Responsive Design: Optimized for desktop, tablet, and mobile devices
- โก Loading States: Elegant loading indicators and error handling
- ๐ฒ Random Photos: Get fresh random photos with one click
- ๐จ Modern Design: Clean, professional interface with gradient backgrounds
- โจ Hover Effects: Smooth animations and photo overlay effects
- ๐ Grid Layout: Responsive CSS Grid for optimal photo arrangement
- ๐ Visual Feedback: Interactive buttons and smooth transitions
Deploy this project to see it in action! Instructions below.
- Frontend: React.js 18
- Build Tool: Vite
- HTTP Client: Axios
- Styling: CSS3 with Grid and Flexbox
- API: Unsplash API
- Node.js (v16 or higher)
- npm or yarn
- Unsplash API key (free from Unsplash Developers)
git clone https://github.com/1234-ad/react-photo-gallery.git
cd react-photo-gallerynpm install
# or
yarn install- Visit Unsplash Developers
- Create a free account
- Create a new application
- Copy your Access Key
Open src/App.jsx and replace the placeholder with your actual API key:
const UNSPLASH_ACCESS_KEY = 'YOUR_ACTUAL_UNSPLASH_ACCESS_KEY';npm run dev
# or
yarn devThe app will be available at http://localhost:5173
react-photo-gallery/
โโโ public/
โโโ src/
โ โโโ App.jsx # Main application component
โ โโโ App.css # Application styles
โ โโโ main.jsx # React entry point
โ โโโ index.css # Global styles
โโโ index.html # HTML template
โโโ package.json # Dependencies and scripts
โโโ vite.config.js # Vite configuration
โโโ README.md # Project documentation
-
Random Photos:
GET https://api.unsplash.com/photos/random?count=10&client_id=YOUR_ACCESS_KEY -
Search Photos:
GET https://api.unsplash.com/search/photos?query=SEARCH_TERM&per_page=10&client_id=YOUR_ACCESS_KEY
- Build the project:
npm run build - Drag and drop the
distfolder to Netlify - Or connect your GitHub repo for automatic deployments
- Install Vercel CLI:
npm i -g vercel - Run:
vercel - Follow the prompts
- Install gh-pages:
npm install --save-dev gh-pages - Add to package.json scripts:
"homepage": "https://1234-ad.github.io/react-photo-gallery", "predeploy": "npm run build", "deploy": "gh-pages -d dist"
- Run:
npm run deploy
In App.jsx, modify the count parameter:
// For random photos
count: 20, // Change from 10 to 20
// For search results
per_page: 20, // Change from 10 to 20In App.jsx, update the tags array:
{['cars', 'flowers', 'boats', 'nature', 'cats', 'architecture', 'travel', 'food'].map((tag) => (
// ... existing code
))}-
API Key Error:
- Ensure your Unsplash API key is correctly set
- Check if the key has proper permissions
-
CORS Issues:
- Unsplash API supports CORS, but ensure you're making requests from allowed origins
-
Rate Limiting:
- Unsplash has rate limits (50 requests/hour for demo apps)
- Consider implementing request caching for production
- Load More Button: Pagination for more photos
- Infinite Scrolling: Automatic loading as user scrolls
- Image Download: Direct download functionality
- Favorites: Save favorite photos to localStorage
- Categories: Browse by photo categories
- Full-Screen View: Modal for enlarged photo viewing
This project is licensed under the MIT License.
- Unsplash for providing the amazing photo API
- Vite for the fast build tool
- React for the awesome framework
โญ If you found this project helpful, please give it a star on GitHub!