A React application that displays NASA's Astronomy Picture of the Day (APOD) using the NASA API.
- Browse 2 weeks of APOD images
- View detailed information for each image
- Responsive design for mobile and desktop
- Loading states and error handling
- Client-side routing with React Router
- React 18
- Vite
- Tailwind CSS
- React Router DOM
- NASA APOD API
- Clone the repository
- Install dependencies:
npm install
- Create a
.envfile in the root directory and add your NASA API key:VITE_API_KEY=your_nasa_api_key_here - Get your NASA API key from: https://api.nasa.gov/
npm run devnpm run build- Cloudflare account
- NASA API key
-
Push your code to GitHub
git add . git commit -m "Ready for deployment" git push origin main
-
Connect to Cloudflare Pages
- Go to Cloudflare Dashboard
- Navigate to Pages
- Click "Create a project"
- Choose "Connect to Git"
- Select your GitHub repository
-
Configure Build Settings
- Framework preset: Vite
- Build command:
npm run build - Build output directory:
dist - Root directory:
/(leave empty)
-
Environment Variables
- Add your NASA API key as an environment variable:
- Variable name:
VITE_API_KEY - Value: Your NASA API key
- Variable name:
- Add your NASA API key as an environment variable:
-
Deploy
- Click "Save and Deploy"
- Your app will be available at
https://your-project-name.pages.dev
Make sure to add these environment variables in your Cloudflare Pages project settings:
VITE_API_KEY: Your NASA API key
src/
├── components/ # Reusable UI components
├── Pages/ # Page components
├── Utils/ # API functions and routing
├── App.jsx # Main app component
└── main.jsx # Entry point
This app uses NASA's APOD API:
fetchAll(): Get 2 weeks of APOD datafetchToday(): Get today's APODfetchSingleDate(date): Get APOD for specific date
MIT