A modern, responsive news website built with React and Vite. This project showcases a complete news application with category browsing, search functionality, and a beautiful user interface.
- Responsive Design: Works perfectly on desktop, tablet, and mobile devices
- Dark/Light Theme: Toggle between themes with persistent storage
- Multiple Categories: Browse news by Technology, Business, Sports, Entertainment, Health
- Search Functionality: Search through articles by title and description
- Article Modal: Click any article to view full details in a popup
- Hero Section: Featured articles prominently displayed on the homepage
- Sort Options: Sort articles by latest, popularity, or relevance
- Load More: Pagination for browsing additional articles
- React Router: Client-side routing for smooth navigation
- React 19 - Modern React with hooks and functional components
- React Router - Client-side routing
- Vite - Fast development server and build tool
- CSS3 - Modern CSS with CSS variables for theming
- Context API - Global state management
- Custom Hooks - Reusable logic for news fetching and theme management
src/
├── components/ # Reusable UI components
│ ├── Header.jsx # Navigation and search
│ ├── NewsCard.jsx # Article display component
│ ├── Modal.jsx # Article detail popup
│ ├── Loading.jsx # Loading state component
│ ├── Error.jsx # Error state component
│ └── Footer.jsx # Site footer
├── pages/ # Page components
│ ├── HomePage.jsx # Home page with hero section
│ └── CategoryPage.jsx # Category-specific pages
├── context/ # React Context providers
│ ├── ThemeContext.jsx # Global theme management
│ └── NewsContext.jsx # Global news state
├── hooks/ # Custom React hooks
│ └── useNews.js # News fetching logic
├── utils/ # Utility functions
│ └── mockNews.js # Mock data and utilities
├── App.jsx # Main app component
├── main.jsx # React entry point
└── style.css # Global styles
- Node.js (v18 or higher)
- npm or yarn
- Clone the repository:
git clone <your-repo-url>
cd project1- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser and visit
http://localhost:5173
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production build
The app currently uses mock data. To integrate with real news APIs:
-
Get an API key from services like:
- NewsAPI.org - 100 free requests/day
- Currents API - Free tier available
- GNews API - 100 free requests/day
-
Update the
useNews.jshook to fetch from real APIs -
Add your API key to environment variables
The app uses CSS variables for easy theming. Modify the :root and [data-theme="dark"] selectors in style.css to customize colors.
This is a learning project! Feel free to:
- Add new features
- Improve the UI/UX
- Add tests
- Integrate with real APIs
- Convert to TypeScript
This project is open source and available under the MIT License.
Built with ❤️ for learning React development