0
# Valibot Presets
1
2
Pre-configured environment variable schemas for popular hosting platforms and services using Valibot validators. These presets provide ready-to-use environment variable configurations for common deployment platforms, using Valibot's modular validation system.
3
4
## Import
5
6
```typescript
7
import {
8
vercel,
9
railway,
10
render,
11
netlify,
12
fly,
13
neonVercel,
14
supabaseVercel,
15
uploadthing,
16
uploadthingV6,
17
upstashRedis,
18
coolify,
19
vite,
20
wxt
21
} from "@t3-oss/env-nextjs/presets-valibot";
22
```
23
24
## Capabilities
25
26
### Vercel System Environment Variables
27
28
Vercel system environment variables for deployment information, Git metadata, and build context using Valibot validation.
29
30
```typescript { .api }
31
/**
32
* Vercel System Environment Variables
33
* @see https://vercel.com/docs/projects/environment-variables/system-environment-variables#system-environment-variables
34
*/
35
function vercel(): Readonly<VercelEnv>;
36
37
interface VercelEnv {
38
VERCEL?: string;
39
CI?: string;
40
VERCEL_ENV?: "development" | "preview" | "production";
41
VERCEL_URL?: string;
42
VERCEL_PROJECT_PRODUCTION_URL?: string;
43
VERCEL_BRANCH_URL?: string;
44
VERCEL_REGION?: string;
45
VERCEL_DEPLOYMENT_ID?: string;
46
VERCEL_SKEW_PROTECTION_ENABLED?: string;
47
VERCEL_AUTOMATION_BYPASS_SECRET?: string;
48
VERCEL_GIT_PROVIDER?: string;
49
VERCEL_GIT_REPO_SLUG?: string;
50
VERCEL_GIT_REPO_OWNER?: string;
51
VERCEL_GIT_REPO_ID?: string;
52
VERCEL_GIT_COMMIT_REF?: string;
53
VERCEL_GIT_COMMIT_SHA?: string;
54
VERCEL_GIT_COMMIT_MESSAGE?: string;
55
VERCEL_GIT_COMMIT_AUTHOR_LOGIN?: string;
56
VERCEL_GIT_COMMIT_AUTHOR_NAME?: string;
57
VERCEL_GIT_PREVIOUS_SHA?: string;
58
VERCEL_GIT_PULL_REQUEST_ID?: string;
59
}
60
```
61
62
### Railway Environment Variables
63
64
Railway platform environment variables for deployment, project, and service information using Valibot validation.
65
66
```typescript { .api }
67
/**
68
* Railway Environment Variables
69
* @see https://docs.railway.app/reference/variables#railway-provided-variables
70
*/
71
function railway(): Readonly<RailwayEnv>;
72
73
interface RailwayEnv {
74
RAILWAY_PUBLIC_DOMAIN?: string;
75
RAILWAY_PRIVATE_DOMAIN?: string;
76
RAILWAY_TCP_PROXY_DOMAIN?: string;
77
RAILWAY_TCP_PROXY_PORT?: string;
78
RAILWAY_TCP_APPLICATION_PORT?: string;
79
RAILWAY_PROJECT_NAME?: string;
80
RAILWAY_PROJECT_ID?: string;
81
RAILWAY_ENVIRONMENT_NAME?: string;
82
RAILWAY_ENVIRONMENT_ID?: string;
83
RAILWAY_SERVICE_NAME?: string;
84
RAILWAY_SERVICE_ID?: string;
85
RAILWAY_REPLICA_ID?: string;
86
RAILWAY_DEPLOYMENT_ID?: string;
87
RAILWAY_SNAPSHOT_ID?: string;
88
RAILWAY_VOLUME_NAME?: string;
89
RAILWAY_VOLUME_MOUNT_PATH?: string;
90
RAILWAY_RUN_UID?: string;
91
RAILWAY_GIT_COMMIT_SHA?: string;
92
RAILWAY_GIT_AUTHOR_EMAIL?: string;
93
RAILWAY_GIT_BRANCH?: string;
94
RAILWAY_GIT_REPO_NAME?: string;
95
RAILWAY_GIT_REPO_OWNER?: string;
96
RAILWAY_GIT_COMMIT_MESSAGE?: string;
97
}
98
```
99
100
### Render System Environment Variables
101
102
Render platform environment variables for service information, Git metadata, and deployment context using Valibot validation.
103
104
```typescript { .api }
105
/**
106
* Render System Environment Variables
107
* @see https://docs.render.com/environment-variables#all-runtimes
108
*/
109
function render(): Readonly<RenderEnv>;
110
111
interface RenderEnv {
112
IS_PULL_REQUEST?: string;
113
RENDER_DISCOVERY_SERVICE?: string;
114
RENDER_EXTERNAL_HOSTNAME?: string;
115
RENDER_EXTERNAL_URL?: string;
116
RENDER_GIT_BRANCH?: string;
117
RENDER_GIT_COMMIT?: string;
118
RENDER_GIT_REPO_SLUG?: string;
119
RENDER_INSTANCE_ID?: string;
120
RENDER_SERVICE_ID?: string;
121
RENDER_SERVICE_NAME?: string;
122
RENDER_SERVICE_TYPE?: "web" | "pserv" | "cron" | "worker" | "static";
123
RENDER?: string;
124
}
125
```
126
127
### Netlify Environment Variables
128
129
Netlify platform environment variables for build context, deployment information, and site metadata using Valibot validation.
130
131
```typescript { .api }
132
/**
133
* Netlify Environment Variables
134
* @see https://docs.netlify.com/configure-builds/environment-variables
135
*/
136
function netlify(): Readonly<NetlifyEnv>;
137
138
interface NetlifyEnv {
139
NETLIFY?: string;
140
BUILD_ID?: string;
141
CONTEXT?: "production" | "deploy-preview" | "branch-deploy" | "dev";
142
REPOSITORY_URL?: string;
143
BRANCH?: string;
144
URL?: string;
145
DEPLOY_URL?: string;
146
DEPLOY_PRIME_URL?: string;
147
DEPLOY_ID?: string;
148
SITE_NAME?: string;
149
SITE_ID?: string;
150
}
151
```
152
153
### Fly.io Environment Variables
154
155
Fly.io platform environment variables for application, machine, and deployment information using Valibot validation.
156
157
```typescript { .api }
158
/**
159
* Fly.io Environment Variables
160
* @see https://fly.io/docs/machines/runtime-environment/#environment-variables
161
*/
162
function fly(): Readonly<FlyEnv>;
163
164
interface FlyEnv {
165
FLY_APP_NAME?: string;
166
FLY_MACHINE_ID?: string;
167
FLY_ALLOC_ID?: string;
168
FLY_REGION?: string;
169
FLY_PUBLIC_IP?: string;
170
FLY_IMAGE_REF?: string;
171
FLY_MACHINE_VERSION?: string;
172
FLY_PRIVATE_IP?: string;
173
FLY_PROCESS_GROUP?: string;
174
FLY_VM_MEMORY_MB?: string;
175
PRIMARY_REGION?: string;
176
}
177
```
178
179
### Neon for Vercel Environment Variables
180
181
Neon database environment variables when integrated with Vercel using Valibot validation.
182
183
```typescript { .api }
184
/**
185
* Neon for Vercel Environment Variables
186
* @see https://neon.tech/docs/guides/vercel-native-integration#environment-variables-set-by-the-integration
187
*/
188
function neonVercel(): Readonly<NeonVercelEnv>;
189
190
interface NeonVercelEnv {
191
DATABASE_URL: string;
192
DATABASE_URL_UNPOOLED?: string;
193
PGHOST?: string;
194
PGHOST_UNPOOLED?: string;
195
PGUSER?: string;
196
PGDATABASE?: string;
197
PGPASSWORD?: string;
198
POSTGRES_URL?: string;
199
POSTGRES_URL_NON_POOLING?: string;
200
POSTGRES_USER?: string;
201
POSTGRES_HOST?: string;
202
POSTGRES_PASSWORD?: string;
203
POSTGRES_DATABASE?: string;
204
POSTGRES_URL_NO_SSL?: string;
205
POSTGRES_PRISMA_URL?: string;
206
}
207
```
208
209
### Supabase for Vercel Environment Variables
210
211
Supabase database and authentication environment variables when integrated with Vercel using Valibot validation.
212
213
```typescript { .api }
214
/**
215
* Supabase for Vercel Environment Variables
216
* @see https://vercel.com/marketplace/supabase
217
*/
218
function supabaseVercel(): Readonly<SupabaseVercelEnv>;
219
220
interface SupabaseVercelEnv {
221
POSTGRES_URL: string;
222
POSTGRES_PRISMA_URL?: string;
223
POSTGRES_URL_NON_POOLING?: string;
224
POSTGRES_USER?: string;
225
POSTGRES_HOST?: string;
226
POSTGRES_PASSWORD?: string;
227
POSTGRES_DATABASE?: string;
228
SUPABASE_SERVICE_ROLE_KEY?: string;
229
SUPABASE_ANON_KEY?: string;
230
SUPABASE_URL?: string;
231
SUPABASE_JWT_SECRET?: string;
232
NEXT_PUBLIC_SUPABASE_ANON_KEY?: string;
233
NEXT_PUBLIC_SUPABASE_URL?: string;
234
}
235
```
236
237
### UploadThing Environment Variables
238
239
UploadThing file upload service environment variables (current version) using Valibot validation.
240
241
```typescript { .api }
242
/**
243
* UploadThing Environment Variables
244
* @see https://docs.uploadthing.com/getting-started/appdir#add-env-variables
245
*/
246
function uploadthing(): Readonly<UploadThingEnv>;
247
248
interface UploadThingEnv {
249
UPLOADTHING_TOKEN: string;
250
}
251
```
252
253
### UploadThing V6 Environment Variables
254
255
UploadThing file upload service environment variables (version 6) using Valibot validation.
256
257
```typescript { .api }
258
/**
259
* UploadThing V6 Environment Variables
260
* @see https://v6.docs.uploadthing.com/getting-started/nuxt#add-env-variables
261
*/
262
function uploadthingV6(): Readonly<UploadThingV6Env>;
263
264
interface UploadThingV6Env {
265
UPLOADTHING_TOKEN: string;
266
}
267
```
268
269
### Upstash Redis Environment Variables
270
271
Upstash Redis database environment variables for REST API access using Valibot validation.
272
273
```typescript { .api }
274
/**
275
* Upstash Redis Environment Variables
276
* @see https://upstash.com/docs/redis/howto/connectwithupstashredis
277
*/
278
function upstashRedis(): Readonly<UpstashRedisEnv>;
279
280
interface UpstashRedisEnv {
281
UPSTASH_REDIS_REST_URL: string;
282
UPSTASH_REDIS_REST_TOKEN: string;
283
}
284
```
285
286
### Coolify Environment Variables
287
288
Coolify self-hosting platform environment variables for deployment and application information using Valibot validation.
289
290
```typescript { .api }
291
/**
292
* Coolify Environment Variables
293
* @see https://coolify.io/docs/knowledge-base/environment-variables#predefined-variables
294
*/
295
function coolify(): Readonly<CoolifyEnv>;
296
297
interface CoolifyEnv {
298
COOLIFY_FQDN?: string;
299
COOLIFY_URL?: string;
300
COOLIFY_BRANCH?: string;
301
COOLIFY_RESOURCE_UUID?: string;
302
COOLIFY_CONTAINER_NAME?: string;
303
SOURCE_COMMIT?: string;
304
PORT?: string;
305
HOST?: string;
306
}
307
```
308
309
### Vite Environment Variables
310
311
Vite build tool environment variables for development and build information using Valibot validation.
312
313
```typescript { .api }
314
/**
315
* Vite Environment Variables
316
* @see https://vite.dev/guide/env-and-mode
317
*/
318
function vite(): Readonly<ViteEnv>;
319
320
interface ViteEnv {
321
BASE_URL: string;
322
MODE: string;
323
DEV: boolean;
324
PROD: boolean;
325
SSR: boolean;
326
}
327
```
328
329
### WXT Environment Variables
330
331
WXT web extension framework environment variables for browser extension development using Valibot validation.
332
333
```typescript { .api }
334
/**
335
* WXT Environment Variables
336
* @see https://wxt.dev/guide/essentials/config/environment-variables.html#built-in-environment-variables
337
*/
338
function wxt(): Readonly<WxtEnv>;
339
340
interface WxtEnv {
341
MANIFEST_VERSION?: 2 | 3;
342
BROWSER?: "chrome" | "firefox" | "safari" | "edge" | "opera";
343
CHROME?: boolean;
344
FIREFOX?: boolean;
345
SAFARI?: boolean;
346
EDGE?: boolean;
347
OPERA?: boolean;
348
}
349
```
350
351
## Usage Examples
352
353
### Using Valibot with Vercel Preset
354
355
```typescript
356
import { createEnv } from "@t3-oss/env-nextjs";
357
import { vercel } from "@t3-oss/env-nextjs/presets-valibot";
358
import { string, pipe, url, minLength } from "valibot";
359
360
const vercelEnv = vercel();
361
362
const env = createEnv({
363
server: {
364
DATABASE_URL: pipe(string(), url()),
365
JWT_SECRET: pipe(string(), minLength(32)),
366
},
367
client: {
368
NEXT_PUBLIC_APP_URL: pipe(string(), url()),
369
},
370
extends: [vercelEnv],
371
runtimeEnv: {
372
DATABASE_URL: process.env.DATABASE_URL,
373
JWT_SECRET: process.env.JWT_SECRET,
374
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
375
// Vercel variables are automatically available
376
},
377
});
378
379
// Access Vercel-specific variables with Valibot validation
380
console.log(env.VERCEL_ENV); // "development" | "preview" | "production" | undefined
381
console.log(env.VERCEL_URL); // string | undefined
382
```
383
384
### Combining Multiple Valibot Presets
385
386
```typescript
387
import { createEnv } from "@t3-oss/env-nextjs";
388
import { vercel, neonVercel } from "@t3-oss/env-nextjs/presets-valibot";
389
import { string, pipe, url, minLength } from "valibot";
390
391
const vercelEnv = vercel();
392
const neonEnv = neonVercel();
393
394
const env = createEnv({
395
server: {
396
JWT_SECRET: pipe(string(), minLength(32)),
397
API_KEY: string(),
398
},
399
client: {
400
NEXT_PUBLIC_APP_URL: pipe(string(), url()),
401
},
402
extends: [vercelEnv, neonEnv],
403
runtimeEnv: {
404
JWT_SECRET: process.env.JWT_SECRET,
405
API_KEY: process.env.API_KEY,
406
NEXT_PUBLIC_APP_URL: process.env.NEXT_PUBLIC_APP_URL,
407
// Both Vercel and Neon variables are available
408
},
409
});
410
411
// Access variables from both presets with Valibot validation
412
console.log(env.VERCEL_ENV); // From Vercel preset
413
console.log(env.DATABASE_URL); // From Neon preset
414
```
415
416
### Using Advanced Valibot Validation
417
418
```typescript
419
import { createEnv } from "@t3-oss/env-nextjs";
420
import { railway } from "@t3-oss/env-nextjs/presets-valibot";
421
import { string, boolean, pipe, transform } from "valibot";
422
423
const railwayEnv = railway();
424
425
const env = createEnv({
426
server: {
427
PORT: pipe(string(), transform(Number)),
428
DEBUG: pipe(string(), transform((val) => val === "true")),
429
},
430
client: {
431
NEXT_PUBLIC_API_URL: string(),
432
},
433
extends: [railwayEnv],
434
runtimeEnv: {
435
PORT: process.env.PORT,
436
DEBUG: process.env.DEBUG,
437
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
438
// Railway variables are automatically available
439
},
440
});
441
442
// Access Railway-specific variables
443
console.log(env.RAILWAY_ENVIRONMENT_NAME); // string | undefined
444
console.log(env.RAILWAY_PROJECT_NAME); // string | undefined
445
console.log(env.PORT); // number (transformed from string)
446
console.log(env.DEBUG); // boolean (transformed from string)
447
```
448
449
### Custom Valibot Validation
450
451
```typescript
452
import { createEnv } from "@t3-oss/env-nextjs";
453
import { netlify } from "@t3-oss/env-nextjs/presets-valibot";
454
import { string, pipe, regex, optional } from "valibot";
455
456
const netlifyEnv = netlify();
457
458
const env = createEnv({
459
server: {
460
DATABASE_URL: pipe(string(), regex(/^postgresql:\/\//)),
461
REDIS_URL: optional(pipe(string(), regex(/^redis:\/\//))),
462
},
463
client: {
464
NEXT_PUBLIC_API_URL: string(),
465
},
466
extends: [netlifyEnv],
467
runtimeEnv: {
468
DATABASE_URL: process.env.DATABASE_URL,
469
REDIS_URL: process.env.REDIS_URL,
470
NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
471
// Netlify variables are automatically available
472
},
473
});
474
475
// Access Netlify-specific variables
476
console.log(env.NETLIFY); // string | undefined
477
console.log(env.CONTEXT); // "production" | "deploy-preview" | "branch-deploy" | "dev" | undefined
478
```