Overview
AiVault requires several environment variables to connect with external services. Create a.env.local file in the root directory and configure the following variables.
Gemini AI Configuration
These variables are automatically injected by AI Studio at runtime.Required for Gemini AI API calls. In AI Studio, this is automatically injected from user secrets configured via the Secrets panel.
The URL where this applet is hosted. AI Studio automatically injects this at runtime with the Cloud Run service URL. Used for self-referential links, OAuth callbacks, and API endpoints.
Clerk Authentication
Configure Clerk for user authentication and session management.Your Clerk publishable key. Get this from your Clerk Dashboard.
Your Clerk secret key. Keep this secure and never commit it to version control.
The URL path for the sign-in page.
The URL path for the sign-up page.
Convex Database
Configure Convex for real-time database and backend functionality.Your Convex deployment name. This is generated when you run
npx convex dev for the first time.Your Convex deployment URL. This is automatically generated by Convex and displayed when running
convex dev.Required for production deployments. Get this from your Convex dashboard under deployment settings.
This is only needed for CI/CD and production deployments. Not required for local development.
Admin Configuration
Control who has access to the admin dashboard.Comma-separated list of Clerk user IDs that should have admin access. Users listed here can access the To find your Clerk user ID:
/admin dashboard to approve or reject tool submissions.- Sign in to your application
- Open browser dev tools
- Check the network tab or localStorage for your user ID
- Or use Clerk Dashboard to view user IDs
Email Configuration (Optional)
Configure Resend for transactional email notifications.Your Resend API key for sending transactional emails. Get this from resend.com.
Email notifications are optional but recommended for production deployments.
The email address that will appear in the “From” field of sent emails. Must be verified in your Resend dashboard.
Admin email address for receiving notifications about new tool submissions.
Example Configuration
Here’s a complete example.env.local file:
Security Best Practices
- Use Different Keys for Development and Production - Create separate Clerk and Convex projects for development and production
- Rotate Keys Regularly - Especially if they may have been exposed
- Limit Admin Access - Only add trusted user IDs to
NEXT_PUBLIC_ADMIN_USER_IDS - Use Environment-Specific Variables - Use different values for development, staging, and production
Verifying Configuration
After setting up your environment variables:- Restart both development servers (Convex and Next.js)
- Check the browser console for any authentication errors
- Try signing in to verify Clerk is working
- Check the Convex dashboard to ensure database connection is active
- Test admin access by navigating to
/admin(if your user ID is in the admin list)
Next Steps
Configuration
Learn about Next.js and configuration files
Database Schema
Understand the Convex database schema