Create a .env.local file in the root directory with the following variables:
# Database Configuration
MONGODB_URI=mongodb://localhost:27017/neonest
# or for MongoDB Atlas: mongodb+srv://username:password@cluster.mongodb.net/neonest
# JWT Secret (generate a strong secret)
JWT_SECRET=your-super-secret-jwt-key-here
# Google Gemini API (for AI features)
GEMINI_API_KEY=- Local MongoDB:
mongodb://localhost:27017/neonest - MongoDB Atlas: Get from your MongoDB Atlas dashboard
- Other: Use your MongoDB connection string
Generate a strong secret key:
# Option 1: Use Node.js
node -e "console.log(require('crypto').randomBytes(64).toString('hex'))"
# Option 2: Use online generator
# Visit: https://generate-secret.vercel.app/64- Go to Google AI Studio
- Create a new API key
- Copy the key to your
.env.localfile
- Copy the example above
- Replace the placeholder values with your actual values
- Save as
.env.localin the project root - Restart your development server
- "MongoDB connection failed": Check your MONGODB_URI
- "JWT_SECRET is not defined": Make sure JWT_SECRET is set
- "Invalid token": Regenerate your JWT_SECRET
- "API key invalid": Check your GEMINI_API_KEY
- Start the server:
npm run dev - Try to sign up a new user
- Try to log in with the created user
- Check if notifications work
- Never commit your
.env.localfile to version control - Use strong, unique secrets for production
- Rotate API keys regularly
- Use environment-specific configurations for different deployments