Loading...
Loading...
Answer questions about ArkEnv and help implement environment variable validation. Use when developers: (1) Ask about environment variable validation or typesafety, (2) Want to setup ArkEnv in a project, (3) Need to define or update schemas using ArkType or Standard Schema, (4) Are integrating with Vite, Bun, or other runtimes. Triggers on: 'ArkEnv', 'env validation', 'typesafe env', 'createEnv', 'env.ts', '@arkenv/cli'.
npx skill4agent add yamcodes/arkenv arkenvArkTypeStandard SchemaZodValibotArkTypeStandard Schemaimport.meta.env@arkenv/vite-pluginprocess.env@arkenv/bun-pluginprocess.envpnpm dlx @arkenv/cli@latest initViteBuntsconfig.json--agentpnpm dlx @arkenv/cli@latest init --agent--agent--yes--quiet--jsonstdoutstderrstatus: "success"env.tsarkenvvite.config.tsbunfig.tomlpackage.jsonpnpm dlx @arkenv/cli@latest initpnpm dlx @arkenv/cli@latest init --agentenv.tsenv.tsenv.tsstringnumber.portvite.config.tsarkenvbunfig.tomlsrc/vite-env.d.tsenv.d.tsinterface ImportMetaEnv extends import("@arkenv/vite-plugin").ImportMetaEnvAugmented<typeof import("./env").Env> {}bun-env.d.ts/// <reference types="bun-types" />
type ProcessEnvAugmented = import("@arkenv/bun-plugin").ProcessEnvAugmented<typeof import("./src/env").default>;
declare namespace NodeJS {
interface ProcessEnv extends ProcessEnvAugmented {}
}tsconfig.jsonstrict: trueprocess.envimport.meta.envpnpm checktypeimport { type } from 'arkenv';
export const Env = type({
NODE_ENV: "'development' | 'production' | 'test' = 'development'",
VITE_API_URL: "string",
PORT: "number.port = 3000"
});import arkenv from 'arkenv';
import { Env } from './env';
export const env = arkenv(Env);
// Usage
const port = env.PORT; // typed as numbervite.config.tsImportMetaEnv// vite.config.ts
import arkenv from '@arkenv/vite-plugin';
import { Env } from './env';
export default defineConfig({
plugins: [arkenv(Env)]
});// src/vite-env.d.ts
import type { ImportMetaEnvAugmented } from "@arkenv/vite-plugin";
import type { Env } from "../env";
interface ImportMetaEnv extends ImportMetaEnvAugmented<typeof Env> {}// src/env.d.ts
import type { ProcessEnvAugmented } from "@arkenv/bun-plugin";
import type { Env } from "./env";
declare global {
namespace NodeJS {
interface ProcessEnv extends ProcessEnvAugmented<typeof Env> {}
}
}initpnpm dlx @arkenv/cli@latest initimport.meta.envprocess.envimport { env }@arkenv/vite-plugin@arkenv/bun-pluginenvimport.meta.envprocess.env.env"3000"3000