Utility for defining environment variables,
which are made available via $app/env/public and $app/env/private.
import{defineEnvVars}from'@sveltejs/kit/env';import*asvfrom'valibot';exportconstvariables=defineEnvVars({API_URL:{schema:v.pipe(v.string(),v.url())},PORT:{schema:(value)=>{if(value===undefined)return3000;constport=Number(value);if(!Number.isInteger(port))thrownewError('PORT must be an integer');returnport;}}});
Utility for defining environment variables,
which are made available via $app/env/public and $app/env/private.
import{defineEnvVars}from'@sveltejs/kit/env';import*asvfrom'valibot';exportconstvariables=defineEnvVars({API_URL:{schema:v.pipe(v.string(),v.url())},PORT:{schema:(value)=>{if(value===undefined)return3000;constport=Number(value);if(!Number.isInteger(port))thrownewError('PORT must be an integer');returnport;}}});
Utility for defining environment variables,
which are made available via $app/env/public and $app/env/private.
import{defineEnvVars}from'@sveltejs/kit/env';import*asvfrom'valibot';exportconstvariables=defineEnvVars({API_URL:{schema:v.pipe(v.string(),v.url())},PORT:{schema:(value)=>{if(value===undefined)return3000;constport=Number(value);if(!Number.isInteger(port))thrownewError('PORT must be an integer');returnport;}}});
Returns true if the value passed is an integer, false otherwise.
number
A numeric value.
(portconstport:number))thrownewErrorvarError:ErrorConstructornew(message?:string,options?:ErrorOptions)=>Error(+1overload)('PORT must be an integer');returnportconstport:number;}}});
A Standard Schema validator that is applied to the value when the app starts.
Alternatively, a function that returns the (possibly transformed) value, or throws an error explaining
the problem. Returning undefined is valid, so a function can describe an optional variable.
The validator can output any value — not necessarily a string — but public, non-static values must be
serializable by devalue so that they can be sent to the browser.
If omitted, the value must be set, but may be an empty string.
description?:string;
A description of the variable that will be used for inline documentation on hover.