|
1 | | -# t3-env-client |
| 1 | +# t3-env-client |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +A web client to manage your environment variables when using the [t3-env](https://github.com/t3-oss/t3-env) library for type-safe environment variable validation. This package provides a beautiful, interactive interface to view, edit, and manage your environment variables directly from your browser. |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- 🔍 **Type-Safe**: Works seamlessly with t3-env for full TypeScript support |
| 10 | +- 🔄 **Environment Switching**: Easily switch between development and production environments |
| 11 | +- ✏️ **Live Editing**: Edit variables and write changes directly to your `.env` files |
| 12 | +- 🔍 **Search & Filter**: Find variables quickly with search and status filtering |
| 13 | +- 📝 **Live Preview**: See generated `.env` file content in real-time |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Install the package globally or as a dev dependency: |
| 18 | + |
| 19 | +```bash |
| 20 | +# Or as a dev dependency |
| 21 | +npm install -D t3-env-client |
| 22 | +``` |
| 23 | + |
| 24 | +## Usage |
| 25 | + |
| 26 | +### Quick Start |
| 27 | + |
| 28 | +Run the client in your project directory: |
| 29 | + |
| 30 | +```bash |
| 31 | +npx t3-env-client |
| 32 | +``` |
| 33 | + |
| 34 | +This will start the web interface at `http://localhost:3010` |
| 35 | + |
| 36 | +### CLI Parameters |
| 37 | + |
| 38 | +The CLI accepts several options to customize its behavior: |
| 39 | + |
| 40 | +```bash |
| 41 | +npx t3-env-client [options] |
| 42 | +``` |
| 43 | + |
| 44 | +| Option | Short | Description | Default | |
| 45 | +|--------|-------|-------------|---------| |
| 46 | +| `--dir <path>` | `-d` | Directory path to your t3-env config | `./` | |
| 47 | +| `--port <port>` | `-p` | Port to run the server on | `3010` | |
| 48 | +| `--verbose` | `-v` | Enable verbose logging | `false` | |
| 49 | + |
| 50 | +## Configuration |
| 51 | + |
| 52 | +Create an `env-client.config.ts` file in your project root to configure the client: |
| 53 | + |
| 54 | +```typescript |
| 55 | +const envClientConfig = { |
| 56 | + envsPath: './envs.ts', |
| 57 | + writePermission: true, |
| 58 | + envFilePath: '.env.local', |
| 59 | +}; |
| 60 | + |
| 61 | +export default envClientConfig; |
| 62 | +``` |
| 63 | + |
| 64 | +### env-client.config.ts Options |
| 65 | + |
| 66 | +| Property | Type | Required | Description | Default | |
| 67 | +|----------|------|----------|-------------|---------| |
| 68 | +| `envsPath` | `string` | ✅ | Path to your t3-env configuration file | - | |
| 69 | +| `writePermission` | `boolean` | ❌ | Enable writing changes to env files | `false` | |
| 70 | +| `envFilePath` | `string` | ❌ | Target file for writing env variables | `.env.local` | |
| 71 | + |
| 72 | +### Configuration Details |
| 73 | + |
| 74 | +#### `envsPath` |
| 75 | +- **Required**: Yes |
| 76 | +- **Description**: Path to your t3-env schema file (usually `envs.ts` or `env.ts`) |
| 77 | +- **Example**: `'./src/env.ts'`, `'./envs.ts'` |
| 78 | + |
| 79 | +#### `writePermission` |
| 80 | +- **Required**: No |
| 81 | +- **Default**: `false` |
| 82 | +- **Description**: When enabled, allows the web interface to write changes back to your env files using the "Update .env" button |
| 83 | +- **Security**: Only enable this in development environments |
| 84 | + |
| 85 | +#### `envFilePath` |
| 86 | +- **Required**: No |
| 87 | +- **Default**: `.env.local` |
| 88 | +- **Description**: The file where environment variables will be written when using the "Update .env" feature |
| 89 | +- **Examples**: `.env.local`, `.env.development`, `.env` |
| 90 | + |
| 91 | +### Example t3-env Setup |
| 92 | + |
| 93 | +Your `envs.ts` file should follow the standard t3-env pattern: |
| 94 | + |
| 95 | +```typescript |
| 96 | +import { createEnv } from "@t3-oss/env-nextjs"; |
| 97 | +import { z } from "zod"; |
| 98 | + |
| 99 | +export const env = createEnv({ |
| 100 | + server: { |
| 101 | + DATABASE_URL: z.string().url(), |
| 102 | + NEXTAUTH_SECRET: z.string().min(1), |
| 103 | + }, |
| 104 | + client: { |
| 105 | + NEXT_PUBLIC_APP_URL: z.string().url(), |
| 106 | + }, |
| 107 | + runtimeEnv: { |
| 108 | + DATABASE_URL: process.env.DATABASE_URL, |
| 109 | + NEXTAUTH_SECRET: process.env.NEXTAUTH_SECRET, |
| 110 | + NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL, |
| 111 | + }, |
| 112 | +}); |
| 113 | +``` |
| 114 | + |
| 115 | +## Development |
| 116 | + |
| 117 | +This package works best when you have: |
| 118 | + |
| 119 | +1. A t3-env setup in your project |
| 120 | +2. Environment files (`.env`, `.env.local`, etc.) |
| 121 | +3. An `env-client.config.ts` configuration file |
| 122 | + |
| 123 | +The web interface will automatically detect your environment variables and provide a clean interface for management. |
| 124 | + |
| 125 | +## License |
| 126 | + |
| 127 | +MIT |
0 commit comments