This guide explains how to set up YouTube integration for the DNA Forge Hub project to automatically fetch videos from the DNA Official Tech channel.
The system works out of the box with mock data. No setup required!
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the YouTube Data API v3:
- Go to "APIs & Services" > "Library"
- Search for "YouTube Data API v3"
- Click on it and press "Enable"
- Create credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "API Key"
- Copy the generated API key
-
Copy
.env.exampleto.env:cp .env.example .env
-
Edit
.envand add your API key:VITE_YOUTUBE_API_KEY=your_actual_api_key_here VITE_YOUTUBE_REFRESH_INTERVAL=60
npm run dev- Automatically checks for new videos every 60 minutes (configurable)
- Graceful fallback to mock data if API fails
- Console logging for monitoring
- Beautiful video cards with thumbnails
- Video duration and view count
- Publish date (relative time)
- Direct links to YouTube
- Search videos by title and description
- Real-time filtering as you type
- Responsive grid and list views
- Video view counts formatted (1.2K, 1.5M views)
- Duration in MM:SS or H:MM:SS format
- Relative publish dates (2 days ago, 1 week ago)
- Channel: DNA Official Tech
- Handle: @dnaofficialtech
- URL: https://youtube.com/@dnaofficialtech
YouTube API has daily quotas:
- Free tier: 10,000 units per day
- Each video fetch: ~3-5 units
- Recommended: Check every 60+ minutes to stay within limits
- Check browser console for error messages
- Verify API key is correct in
.env - Ensure YouTube Data API v3 is enabled
- Check API quota hasn't been exceeded
- Make sure the API key has no restrictions that block YouTube Data API
- Try regenerating the API key
- Verify the correct project is selected in Google Cloud Console
- Without API key: Shows 8 sample videos
- With API key: Shows real videos from DNA Official Tech channel
The system automatically:
- Fetches latest videos on page load
- Sets up auto-refresh interval
- Handles errors gracefully
- Provides detailed console logging
- API key is only used client-side for this demo
- For production, consider server-side API calls
- Never commit real API keys to version control
- Use environment variables for sensitive data