AstroWorld now integrates multiple NASA APIs to provide real-time space data and stunning imagery directly on the home page.
- Displays NASA's Astronomy Picture of the Day as a cinematic hero banner
- Includes title, date, and copyright information
- Smooth fade-in animations
- Real-time notifications from NASA's Space Weather Database Of Notifications
- Displays solar flares, coronal mass ejections, and other space weather events
- Card-based layout with animations
- Shows asteroids and comets passing close to Earth
- Highlights potentially hazardous asteroids (PHA)
- Displays diameter, velocity, and miss distance
- Updates daily
- Latest photos of Earth from the DSCOVR satellite
- 1 million miles away from Earth perspective
- Lightbox view for full-size images
- Natural color imagery
- Recent images from NASA's Curiosity rover
- Shows camera type and capture date
- Interactive gallery with full-screen view
- Real photos from the Red Planet
- Live count of confirmed exoplanets
- Data from NASA/Caltech Exoplanet Archive
- Animated counter with sparkle effects
- Statistics cards showing diversity
- Animated canvas-based starfield
- Twinkling stars with varying sizes
- Cosmic nebula overlays
- Shooting star effects
- Fully responsive
Visit NASA API Portal and sign up for a free API key.
Create a .env file in astroworld-frontend/ directory:
# Copy from .env.example
cp .env.example .envEdit .env and add your NASA API key:
VITE_NASA_API_KEY=your_actual_api_key_hereNote: You can use DEMO_KEY for testing, but it has rate limits (30 requests/hour, 50 requests/day).
cd astroworld-frontend
npm installnpm run devVisit http://localhost:5173 to see the updated home page with NASA data.
| API | Endpoint | Purpose |
|---|---|---|
| APOD | /planetary/apod |
Astronomy Picture of the Day |
| DONKI | /DONKI/notifications |
Space weather alerts |
| NeoWs | /neo/rest/v1/feed |
Near-Earth asteroids |
| EPIC | /EPIC/api/natural |
Earth imagery |
| Mars Rovers | /mars-photos/api/v1/rovers/{rover}/latest_photos |
Mars photos |
| Exoplanet Archive | Caltech TAP Service | Confirmed exoplanet count |
- 30 requests per hour
- 50 requests per day
- 1,000 requests per hour
- No daily limit
src/
├── services/
│ └── nasa/
│ └── nasaAPI.ts # Centralized NASA API client
├── hooks/
│ └── nasa/
│ ├── useApod.ts # APOD hook
│ ├── useDonki.ts # DONKI hook
│ ├── useNeoWs.ts # NeoWs hook
│ ├── useEpic.ts # EPIC hook
│ ├── useMars.ts # Mars hook
│ └── useExoplanets.ts # Exoplanet hook
└── components/
└── Home/
├── ApodHero.tsx # Hero with APOD
├── StarryBackground.tsx # Animated stars
├── DonkiPanel.tsx # Space weather
├── NeoWsPanel.tsx # Asteroids
├── EpicPanel.tsx # Earth images
├── MarsPanel.tsx # Mars photos
└── ExoplanetStat.tsx # Exoplanet counter
Edit the hook parameters in Home.tsx:
// Show more/fewer items
<DonkiPanel /> // Default: 6 events
<NeoWsPanel /> // Default: 6 objects
<EpicPanel /> // Default: 6 images
<MarsPanel /> // Default: 6 photosIn MarsPanel.tsx, change the rover name:
const { photos } = useMars('curiosity', 6); // or 'opportunity', 'spirit'All components use Framer Motion. Adjust transition values:
<motion.div
initial={{ opacity: 0, y: 20 }}
whileInView={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6 }} // Adjust duration
>- Caching: Hooks use local state; consider adding React Query for better caching
- Loading States: All components show skeleton loaders
- Error Handling: Graceful fallbacks for API failures
- Lazy Loading: Images use
loading="lazy"attribute - Background: Canvas-based stars are performance-optimized
- Verify key in
.envfile - Restart development server after changing
.env - Check console for error messages
- Upgrade from DEMO_KEY to personal key
- Implement caching layer
- Reduce component refresh rates
- Check CORS settings
- Verify NASA API status at status.nasa.gov
- Check network tab for failed requests
- Reduce star count in
StarryBackground.tsx - Limit number of components on page
- Enable browser hardware acceleration
- Add ISS tracking (using ISS location API)
- Implement solar system 3D visualization
- Add Webb Telescope imagery
- Include astronomical events calendar
- Add user favorites/bookmarking
- Implement data caching with service workers
- Add sharing functionality for images
- Create downloadable reports
All data and imagery provided by NASA and its partners. AstroWorld is not affiliated with or endorsed by NASA.