Environment Variables
Relevant source files
The following files were used as context for generating this wiki page:
Environment variables manage the configuration, security, and integration settings for the Inkweave Admin application. These variables control database connections, authentication providers, and deployment-specific behavior on the Vercel platform.
The application uses a strictly validated approach to configuration. It prevents the server from starting if required variables are missing or incorrectly formatted. This ensures that the admin tools, which operate behind a Vercel login, remain secure and functional.
Sources: README.md:1-5, src/env.js:1-10
Configuration and Validation Logic
The application processes environment variables through a centralized validation script. This script utilizes the zod library and @t3-oss/env-nextjs to enforce type safety.
Validation Workflow
The system distinguishes between server-side variables and client-side variables. Server-side variables remain hidden from the browser, while client-side variables require a specific prefix for exposure.
This diagram illustrates the validation gate that environment variables must pass before the application initializes.
Sources: src/env.js:7-60, next.config.js:1-5
Key Environment Variables
The following tables summarize the mandatory and optional variables required for the project.
Core System Variables
| Variable | Requirement | Description |
|---|---|---|
DATABASE_URL | Required | The connection string for the PostgreSQL database. |
NODE_ENV | Required | Defines the environment (development, test, or production). |
NEXTAUTH_SECRET | Required | A secret string used to sign and encrypt session cookies. |
NEXTAUTH_URL | Required | The canonical URL of the application for NextAuth redirects. |
Sources: src/env.js:12-35, .env.example:1-10
Authentication (NextAuth Providers)
Inkweave Admin relies on external providers for identity management.
| Variable | Purpose |
|---|---|
DISCORD_CLIENT_ID | Integrates Discord OAuth for administrative access. |
DISCORD_CLIENT_SECRET | Secret key for Discord OAuth communication. |
Sources: src/env.js:20-25, .env.example:12-15
Security and Deployment
The project deploys to Vercel and enforces access control via Vercel login. The configuration ensures that sensitive keys, such as database credentials and OAuth secrets, never reach the client-side bundle.
- Copy
.env.exampleto a new file named.env. - Populate the variables with your local or production credentials.
- Ensure
NEXTAUTH_URLmatches your deployment domain on Vercel. - Prefix any variable intended for the browser with
NEXT_PUBLIC_.
// Example of validation schema in src/env.js
export const env = createEnv({
server: {
DATABASE_URL: z.string().url(),
NODE_ENV: z.enum(["development", "test", "production"]),
NEXTAUTH_SECRET: process.env.NODE_ENV === "production"
? z.string().min(1)
: z.string().min(1).optional(),
},
runtimeEnv: process.env,
});
Sources: src/env.js:7-45, README.md:3-5
Submodule Integration
Because this repository pins the main Inkweave application as a submodule, environment variables must align with the schemas defined in upstream/inkweave. Inconsistencies between the admin environment and the upstream database schema will cause runtime exceptions during data operations.
Sources: README.md:3, package.json:5-10
Environment variables serve as the backbone for the Inkweave Admin security model. By enforcing strict validation and separating concerns between server and client, the system protects sensitive administrative tools and ensures stable deployments.