Environment Variables
Store API keys and configuration safely using .env files in your Motia apps.
Environment Variables
Environment variables let you store API keys, database URLs, and other configuration outside your code. This keeps sensitive information secure and makes it easy to use different settings for development and production.
Quick Setup
1. Create a .env File
Create a .env file in your project root:
2. Add to .gitignore
Make sure you never commit your .env file:
3. Create Template for Your Team
Using Environment Variables in Steps
TypeScript/JavaScript
Python
Redis Configuration
Motia uses Redis for internal coordination. By default, it includes an embedded in-memory server for development, so you don't need to install or configure Redis separately.
For production or when using an external Redis instance, configure Redis via your config.yaml file using the REDIS_URL environment variable:
The ${REDIS_URL:redis://localhost:6379} syntax uses environment variable interpolation with a default value. See the Configuration and Deployment Guide for complete examples.
Deployment
When you deploy your app, set environment variables through your hosting platform:
Motia Cloud
Important Security Tips
Keep Your Keys Safe
- Never commit
.envfiles to git - Use different API keys for development and production
- Don't share API keys in code or messages
That's it! Environment variables are simple - just put them in .env and use process.env.VARIABLE_NAME in your code.