Skip to main content
SkyCast IA uses environment variables to configure API keys, security settings, and external services. This page provides a complete reference for all variables used in the application.

Environment File Setup

Create a .env.local file in the root directory of your project:
touch .env.local
Never commit your .env.local file to version control. It should already be included in .gitignore.

Required Variables

These environment variables are required for the application to function properly.

OpenWeatherMap API Key

NEXT_PUBLIC_OPENWEATHER_API_KEY
string
required
API key for accessing OpenWeatherMap services (current weather, forecasts, and maps).Used in:
  • src/lib/api/weather.ts:1 - Weather data fetching
  • src/components/ui/WeatherMap.tsx:56 - Interactive weather maps
  • src/components/ui/SearchCity.tsx:69 - City search autocomplete
Example:
NEXT_PUBLIC_OPENWEATHER_API_KEY=a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6
This variable is prefixed with NEXT_PUBLIC_ because it’s used in client-side components. This means it will be exposed to the browser.

Groq API Key

GROQ_API_KEY
string
required
API key for Groq’s AI services, used for weather analysis and the chat feature.Used in:
  • src/lib/api/mistral.ts:9 - AI weather analysis (blue card)
  • src/app/api/chat/route.ts:7 - Interactive chat responses
Model used: llama-3.1-8b-instantExample:
GROQ_API_KEY=gsk_1234567890abcdefghijklmnopqrstuvwxyz
This is a server-side variable (no NEXT_PUBLIC_ prefix). It’s only accessible in API routes and Server Actions, keeping your key secure.

reCAPTCHA Keys

NEXT_PUBLIC_RECAPTCHA_SITE_KEY
string
required
Google reCAPTCHA v2 site key for client-side validation.Used in:
  • src/components/ui/WeatherChat.tsx:51 - Chat security validation
Example:
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI
RECAPTCHA_SECRET_KEY
string
required
Google reCAPTCHA v2 secret key for server-side validation.Used in:
  • src/app/api/chat/route.ts:8 - Verifying chat requests
Example:
RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe
The reCAPTCHA secret key must never be exposed to the client. Keep it server-side only.

News API Key

NEWS_API_KEY
string
required
API key for GNews.io to fetch weather-related news articles.Used in:
  • src/app/api/news/route.ts:6 - Fetching weather and environmental news
Example:
NEWS_API_KEY=1a2b3c4d5e6f7g8h9i0j1k2l3m4n5o6p

Complete .env.local Template

Copy this template to create your .env.local file:
# OpenWeatherMap API (Client-side)
NEXT_PUBLIC_OPENWEATHER_API_KEY=your_openweather_api_key_here

# Groq AI API (Server-side)
GROQ_API_KEY=your_groq_api_key_here

# Google reCAPTCHA v2 (Client-side)
NEXT_PUBLIC_RECAPTCHA_SITE_KEY=your_recaptcha_site_key_here

# Google reCAPTCHA v2 (Server-side)
RECAPTCHA_SECRET_KEY=your_recaptcha_secret_key_here

# GNews API (Server-side)
NEWS_API_KEY=your_gnews_api_key_here

Security Considerations

Public Variables (NEXT_PUBLIC_*):
  • Exposed to the browser
  • Visible in client-side JavaScript
  • Use only for APIs that support browser-based authentication
  • Example: OpenWeatherMap, reCAPTCHA site key
Private Variables (no prefix):
  • Only accessible on the server
  • Never exposed to the browser
  • Use for sensitive keys and secrets
  • Example: Groq API key, reCAPTCHA secret key, News API key
Best practices for rotating API keys:
  1. Generate a new key from the provider’s dashboard
  2. Add the new key to your .env.local file
  3. Test the application locally
  4. Update the key in your production environment (Vercel, etc.)
  5. Revoke the old key after confirming the new one works
Important limits to be aware of:
  • OpenWeatherMap Free Tier: 1,000 calls/day, 60 calls/minute
  • Groq Free Tier: Rate limits vary by model
  • reCAPTCHA: No strict limits for legitimate traffic
  • GNews.io: Varies by plan (typically 100-10,000 requests/day)
Monitor your usage to avoid hitting limits in production.
Never commit API keys to Git:
  • Always use .env.local for local development
  • Use platform environment variables for production (Vercel, Railway, etc.)
  • Never hardcode keys in source code
  • Review commits before pushing to ensure no keys are included

Validation

To verify your environment variables are loaded correctly:
npm run dev
Check the console for error messages like:
  • "Error: GROQ_API_KEY no configurada en las variables de entorno"
  • "Faltan llaves de API. ⚙️"
If you see these messages, double-check your .env.local file.

Next Steps

Get API Keys

Learn how to obtain all required API keys from their respective providers.

Deploy to Production

Configure environment variables for production deployment on Vercel.

Build docs developers (and LLMs) love