Skip to content

Latest commit

 

History

History
439 lines (280 loc) · 18.6 KB

File metadata and controls

439 lines (280 loc) · 18.6 KB

@arkenv/nextjs

0.1.6

Patch Changes

  • Widen the React peer dependency range #1833 230ed72 @yamcodes

    Allow @arkenv/nextjs to work with React 18.2.0 and later in the React 18 line, as well as every React 19 release, instead of requiring React 19.2.5. Install it alongside a supported React version, such as pnpm add @arkenv/nextjs react@^18.2.0.

0.1.5

Patch Changes

  • Make missing-schema errors short and actionable across hosts #1490 9de492a @yamcodes

    When Bun, Next, or Nuxt cannot find an env schema, throw a consistent message that names the expected path / schemaPath and points to npx @arkenv/cli@latest init, without embedding a starter env.ts module.

    Example:

    [ArkEnv] Could not find schema file at src/env.ts or env.ts. Please specify 'schemaPath' in ArkEnv options (or run `npx @arkenv/cli@latest init`).
    
  • Make env/internal/shared.ts optional in strict layout #1503 0b17e32 @yamcodes

    Strict layout now works with just client.ts and server.ts. Omit internal/shared.ts when you have nothing to share — shared keys are treated as empty.

    // env/client.ts + env/server.ts alone is enough
    export default withArkEnv(nextConfig, {
      layout: "strict",
    });

    The CLI still scaffolds shared.ts by default for convenience.

Updated 1 dependency

9de492a 0b17e32

  • @arkenv/build@0.0.3

0.1.4

Patch Changes

  • Improve npm keywords across published packages for discoverability #1383 bf60ab2 @yamcodes

    Clean up and extend the keywords field of every published package so npm search, aggregators, and LLM-powered package discovery surface ArkEnv for the terms users actually search for.

    • Remove the misleading pnpm keyword from arkenv and add env, environment-variables, dotenv, config, standard-schema, and the supported validators zod and valibot.
    • Deduplicate the repeated arkenv keyword in @arkenv/vite-plugin.
    • Give every env-related package a shared baseline (env, environment-variables, dotenv, config, validation, typesafe, standard-schema) alongside their integration-specific terms.
    • Add a keyword set to @arkenv/fumadocs-ui, which previously had none.
Updated 1 dependency

bf60ab2

  • arkenv@0.12.3

0.1.3

Patch Changes

Updated 1 dependency

be8034f

  • @arkenv/build@0.0.2

0.1.2

Patch Changes

  • Add build-time environment variable validation #1233 6386076 @yamcodes

    Automatically validate all required environment variables at build time (e.g. during next build) inside the config plugin. Missing or malformed environment variables will cause the build to fail immediately with a clear, actionable ArkEnv error, preventing runtime failures.

  • Add codegen: false option to @arkenv/nextjs/config #1236 062034f @yamcodes

    Add a codegen option to withArkEnv and setupArkEnv that disables automatic env.gen.ts generation while keeping build-time environment validation active.

    Usage:

    import { withArkEnv } from "@arkenv/nextjs/config";
    import type { NextConfig } from "next";
    
    const nextConfig: NextConfig = {};
    export default withArkEnv(nextConfig, { codegen: false });

    When codegen is false, provide a manual runtimeEnv mapping in your schema file. The CLI's --no-codegen flag now also skips generating env.gen.ts during scaffolding while still wrapping next.config.ts with withArkEnv(nextConfig, { codegen: false }).

0.1.1

Patch Changes

  • Add Flat Layout Mode for Next.js integration #1218 2343378 @yamcodes

    Introduce a new "Flat" layout mode for @arkenv/nextjs. The Flat API allows developers to define a flat schema mapping directly to their .env file structure:

    import arkenv from "./generated/env.gen";
    
    export const env = arkenv(
      {
        DATABASE_URL: "string",
        NEXT_PUBLIC_API_URL: "string",
        NODE_ENV: "'development' | 'production' | 'test' = 'development'",
        CUSTOM_VAR: "string",
      },
      {
        exposeToClient: ["CUSTOM_VAR"],
      }
    );
    • Automatically expose NEXT_PUBLIC_ variables and custom keys specified in options.exposeToClient to the client.
    • Secure server-only variables at runtime via a Proxy that throws on unauthorized client access.
    • Share NODE_ENV implicitly to match standard Next.js build-time inlining behavior.
    • Rename the configuration layout option value from "simple" to "flat". "simple" is kept as a deprecated runtime alias and will be removed in the next major version.
    • Update CLI scaffolding to generate the Flat layout by default.
    • Update documentation and playground/example apps to use and recommend the Flat layout strategy.
  • Deprecate Next.js nested layout and add CLI --flat flag #1218 2343378 @yamcodes

    • Deprecate the legacy nested options overload signature of createEnv in @arkenv/nextjs.
    • Add a one-time development-only runtime warning nudge when the legacy nested layout format is detected.
    • Add the --flat flag to @arkenv/cli to scaffold the recommended flat layout for Next.js.
    • BREAKING CHANGE: Drop support for the @arkenv/cli --simple flag on Next.js projects; passing it now hard-fails with an error. Run npx arkenv init instead (the flat layout is now the default).
    • Remove the nested layout choice from the Next.js interactive CLI prompt, defaulting to flat.
    • Remove the standalone nested layout documentation page and redirect its URL to the FAQ.
    • Update the documentation to guide users from the legacy nested layout to the recommended flat layout.
  • Add standalone setup API and dynamic client environment variables support #1218 2343378 @yamcodes

    Improve the Next.js developer experience with the following enhancements:

    • Expose setupArkEnv from @arkenv/nextjs/config as a non-wrapping alternative to withArkEnv. Use it directly when you are already juggling multiple config wrappers and want to avoid another withX(...) layer.
    • Remove the @arkenv/nextjs/register side-effect import; use withArkEnv for the idiomatic wrapper path or setupArkEnv for the non-wrapping path.
    • Support runtime-injectable client-side variables via a new <ArkEnvScript /> component, enabling containerized deployments to configure public client-side variables dynamically without rebuilds.
    • Fix typesafety for the flat layout so that env returns a strongly-typed schema (rather than resolving to any) and server-side variables can be accessed in server components without TypeScript compile errors.

    Usage:

    // next.config.ts
    import { withArkEnv } from "@arkenv/nextjs/config";
    import type { NextConfig } from "next";
    
    const nextConfig: NextConfig = {};
    export default withArkEnv(nextConfig);
    // app/layout.tsx
    import { ArkEnvScript } from "@arkenv/nextjs";
    
    export default function RootLayout({ children }) {
      return (
        <html lang="en">
          <body>
            <ArkEnvScript />
            {children}
          </body>
        </html>
      );
    }

0.1.0

Minor Changes

  • Enforce strict intersection typing on runtimeEnv and reject legacy configs #1206 12ed4f3 @yamcodes

    Restored strict intersection types (Record<RequiredKeys, unknown> & Record<string, unknown>) on the Next.js createEnv adapter to guarantee compile-time enforcement of required schema keys. Additionally, narrowed the accepted runtimeEnv record value type to string | undefined to actively reject invalid configurations.

    BREAKING CHANGE: If you were using the legacy Next.js env object configuration (e.g., passing a nested object to runtimeEnv), or if you were failing to explicitly map all required keys into runtimeEnv, your build will now fail with a TypeScript error. You must explicitly map all variables referenced in your schema as string | undefined.

    Usage:

    import { createEnv } from "@arkenv/nextjs";
    
    export const env = createEnv({
      client: { NEXT_PUBLIC_API: "string" },
      runtimeEnv: {
        // TypeScript will error if NEXT_PUBLIC_API is missing,
        // and will also error if you try to pass an object or array.
        NEXT_PUBLIC_API: process.env.NEXT_PUBLIC_API,
      },
    });

Patch Changes

Updated 1 dependency

a3e32db 12ed4f3 12ed4f3

  • arkenv@0.12.2

0.0.9

Patch Changes

Updated 1 dependency

3bfbcb7

  • arkenv@0.12.1

0.0.8

Patch Changes

Updated 1 dependency

88b0eee

  • arkenv@0.12.0

0.0.7

Patch Changes

  • Fix development watcher memory and file descriptor leak #1136 593509a @yamcodes

    Store the active chokidar watcher instance on globalThis.__arkenv_watcher__ and close it when configuring a new watcher instance.

  • Remove @deprecated JSDoc tag from createEnv and arkenv in the main and react-server entries #1139 fae4c1f @yamcodes

    Avoid warning users when they call createEnv manually without using the codegen workflow.

0.0.6

Patch Changes

  • Fix env.gen import path in strict layout and export default alias #1121 e75194e @yamcodes

    Correct the hardcoded import path to generated factory in Next.js 3-file strict mode client template. Also export createEnv as default export (aliased as arkenv) in the generated env.gen.ts file.

0.0.5

Patch Changes

  • Generate tailored createEnv factory in Next.js strict layout #1116 b62ebbd @yamcodes

    Generate a tailored createEnv factory helper in env.gen.ts when using the strict split-schema layout (instead of exporting a raw runtimeEnv object).

    This eliminates the need to manually declare or reference the runtimeEnv object inside the client schema client.ts file, aligning it closer to the core arkenv experience of simply calling createEnv(schema, options).

    Example usage in client.ts:

    import { createEnv } from "./generated/env.gen";
    import { SharedSchema } from "./internal/shared";
    
    export const env = createEnv(
      {
        NEXT_PUBLIC_API_URL: "string",
      },
      {
        extends: [SharedSchema],
      }
    );
  • Support split schema layout in Next.js config wrapper #1116 b62ebbd @yamcodes

    Add support for the strict split schema layout in the Next.js withArkEnv configuration wrapper and update CLI scaffolding instructions:

    • Add a layout option ("simple" | "strict") to withArkEnv configuration, which defaults to auto-detecting the strict layout if split files (env/internal/shared.ts, env/client.ts, env/server.ts) exist.
    • Implement key extraction from strict client and shared schema files.
    • Update CLI next-steps messages to include withArkEnv wrapping instructions for strict layout nextjs projects.

0.0.4

Patch Changes

  • Implement Next.js separate files mode, shared entry point, and native extends API #1084 d921785 @yamcodes

    Introduce dedicated entry points for @arkenv/nextjs/server, @arkenv/nextjs/client, and @arkenv/nextjs/shared to prevent metadata leakage and support compile-time bundler-enforced isolation. Add a native extends API to merge validated outputs of extended proxies while maintaining proxy-level protections.

    Also update the CLI init wizard to support interactive layout selection (Strict 3-file vs Simple 1-file) and --strict / --simple flags to bypass interactive selection.

    Example server usage:

    import { createEnv } from "@arkenv/nextjs/server";
    import { env as clientEnv } from "./env.client";
    
    export const env = createEnv(
      { DATABASE_URL: "string" },
      { extends: [clientEnv] }
    );

    Example client usage:

    import { createEnv } from "@arkenv/nextjs/client";
    
    export const env = createEnv(
      { NEXT_PUBLIC_API_URL: "string" },
      {
        runtimeEnv: {
          NEXT_PUBLIC_API_URL: process.env.NEXT_PUBLIC_API_URL,
        },
      }
    );
  • Add withArkEnv configuration helper for Next.js #1092 c6c30ab @yamcodes

    Add a Next.js configuration wrapper in @arkenv/nextjs/config that automates client-side and shared environment variable destructuring in the runtimeEnv block:

    // next.config.ts
    import { withArkEnv } from "@arkenv/nextjs/config";
    import type { NextConfig } from "next";
    
    const nextConfig: NextConfig = {
      reactStrictMode: true,
    };
    
    export default withArkEnv(nextConfig);

    Key features:

    • Zero-Boilerplate Destructuring: Statically extract client and shared keys from your env.ts schema and generate a tailored createEnv factory in generated/env.gen.ts that pre-fills the runtimeEnv block.
    • Development Watcher: Automatically start a lightweight file watcher in development mode to regenerate generated/env.gen.ts on the fly when env.ts changes.
    • Customizable Output: Support custom schema and output paths, enabling developers to write generated files to a dedicated folder (e.g., src/generated/env.gen.ts).
    • Deprecate Direct Exports: Mark direct createEnv and default arkenv exports from the main and react-server entry points as deprecated to steer developers toward the new codegen workflow.

    Example usage in env.ts:

    // env.ts
    import { createEnv } from "./generated/env.gen";
    
    export const env = createEnv({
      client: {
        NEXT_PUBLIC_API_URL: "string",
      },
      shared: {
        NODE_ENV: "string",
      },
    });
Updated 1 dependency

c6c30ab

  • arkenv@0.11.1

0.0.3

Patch changes

  • Fix Next.js schema string autocomplete #1079 bbab725 @pullfrog

    Provide ArkType DSL contextual typing for server, client, and shared schema values.

0.0.2

Patch changes

  • Fix client variable type inference 3531758 @yamcodes

    Client environment variables now correctly infer their validated type instead of resolving to never for non-NEXT_PUBLIC_ keys.

    const env = createEnv({
      client: {
        NEXT_PUBLIC_API_URL: "string",
      },
      runtimeEnv: {
        NEXT_PUBLIC_API_URL: "https://api.example.com",
      },
    });
    
    env.NEXT_PUBLIC_API_URL; // previously `never`, now `string`

0.0.1

Patch changes