Skip to content

Releases: ReesMorris/next-dynamic-env

[email protected]

28 Aug 11:57
030f0ab

Choose a tag to compare

Patch Changes

[email protected]

27 Aug 16:03
78dec6e

Choose a tag to compare

Patch Changes

[email protected]

21 Aug 21:29
09c8021

Choose a tag to compare

Minor Changes

  • #19 70251b4 Thanks @ReesMorris! - Add automatic build phase detection for Docker deployments

    • Skip validation during next build to support Docker workflows where environment variables are injected at runtime
    • Apply schema transformations (defaults, coercion) even when validation is skipped
    • Add isBuildPhase() utility to detect Next.js build phase
    • Examples now use force-dynamic to ensure runtime environment variables work correctly

    This enables true "build once, deploy anywhere" workflows - build your Docker image without environment variables, then inject them at runtime in each environment.

[email protected]

21 Aug 20:48
87c34b6

Choose a tag to compare

Minor Changes

  • #16 0f042b0 Thanks @ReesMorris! - Improved validation error formatting with colors and better readability

    • Added ANSI color support for terminal output (respects NO_COLOR/FORCE_COLOR env vars)
    • Validation errors now display with emoji indicators and colored formatting
    • Simplified error messages by removing verbose JSON arrays and stack traces
    • Changed throw mode behavior to console.error + process.exit instead of throwing
    • Better separation of concerns with modular formatting utilities
    • Improved browser compatibility by detecting environment and adjusting output

[email protected]

21 Aug 13:03

Choose a tag to compare

Patch Changes

[email protected]

21 Aug 00:32
64581f8

Choose a tag to compare

Major Changes

  • 94fea55 Thanks @ReesMorris! - ## 🚀 v1.0.0 - Production Ready Release!

    This marks the first stable release of next-dynamic-env, bringing type-safe runtime environment variables to Next.js applications.

    Major Features

    • Runtime Configuration: Change environment variables without rebuilding your Next.js app
    • Type Safety: Full TypeScript support with autocompletion and type inference
    • Security First: Strict server/client separation - server secrets never reach the browser
    • Universal Validator Support: Works with Zod, Yup, Valibot, or any standard-schema validator
    • Framework Agnostic: Supports App Router, Pages Router, middleware, and instrumentation
    • Docker & Kubernetes Ready: Perfect for containerized deployments

    Key Capabilities

    • createDynamicEnv for defining type-safe environment configurations
    • DynamicEnvScript component for client-side injection
    • waitForEnv utility for async environment loading
    • Empty string to undefined conversion for better validation
    • Custom error handlers and validation strategies
    • XSS protection with automatic script tag filtering

    Documentation

    • Comprehensive README with clear examples
    • Full API reference
    • Example projects for App Router and Pages Router
    • Contributing guidelines

    This release has been thoroughly tested with 187 tests and is ready for production use.

    Special thanks to t3-env for the inspiration!

[email protected]

21 Aug 00:03
a48a7c4

Choose a tag to compare

Minor Changes

  • #11 6a22f62 Thanks @ReesMorris! - feat: separate client and server environments for enhanced security

    Breaking Changes:

    • createDynamicEnv now returns { clientEnv, serverEnv } instead of a single env object
    • DynamicEnvScript now only accepts ClientEnv type
    • Removed backward compatibility with combined environment object

    Security Fix:

    • Server-only environment variables can no longer be accidentally exposed to the browser through React Server Components

    Migration:

    // Before
    const env = createDynamicEnv({ client: {...}, server: {...} });
    <DynamicEnvScript env={env} />
    
    // After
    const { clientEnv, serverEnv } = createDynamicEnv({ client: {...}, server: {...} });
    <DynamicEnvScript clientEnv={clientEnv} />

    Additional Improvements:

    • Added TypeScript discriminators (__isClient and __isServer) for compile-time type safety
    • Made processEnvironmentVariables a pure function
    • Removed duplicate key checking as environments are now separate

v0.1.0

20 Aug 11:50

Choose a tag to compare

What's Changed

Commits

  • Update lockfile (89c771f)
  • Add CI files (8e52a77)
  • Update FUNDING.yml (ed78cf2)
  • Create FUNDING.yml (be05819)
  • Update readme (e02bdf2)
  • Upgrade dependencies (927adef)
  • Remove varName option (4f1c667)
  • Always filter raw values regardless of environment (153d7b8)
  • Revert "Fix bug with onValidationError" (51b8010)
  • Fix bug with onValidationError (74a9ab2)
  • Implement server/client separation for environment variables (b26d818)
  • Add and test Dockerfile (11bf01e)
  • Ignore peer dependencies in Syncpack (0fb1250)
  • Fix lint script in pages router example file (7b56a27)
  • Add schema validation support with Zod (56dd931)
  • Optimise tsup config (393e461)
  • Enhance waitForEnv script (5617c52)
  • Upgrade next (9cd8c9d)
  • Fix script issue (afdcf5b)
  • Fix issue with aliases in build breaking types (d054152)
  • Fix issue with __raw not being detected (22a29b5)
  • Add unit tests (a9ff43e)
  • Upgrade dependencies (068e7ac)
  • Add custom variable name option (8a5cc73)
  • Improve dynamic env handling for client-side access (dcba6b3)
  • Refactor dynamic env to use property access (0a47a65)
  • Update global variable name to be more specific (be68770)
  • Sanitize dynamic env vars for security (aa2b551)
  • Update isBrowser utility (032e2d2)
  • Rename createEnv to createDynamicEnv (50baed3)
  • Rename to next-dynamic-env (8dca952)
  • Move into packages folder (bd49cfc)
  • Add a Next App Router example (7949d86)
  • Set up env scripts (640c989)
  • Set up project with linting and formatting (6931ab5)
  • Initial commit (312c363)

Contributors

Full Changelog: ...v0.1.0

[email protected]

20 Aug 17:09
64f9e37

Choose a tag to compare

Minor Changes

  • 5aed912 Thanks @ReesMorris! - Add emptyStringAsUndefined option to automatically convert empty environment variable strings to undefined

    This new option (enabled by default) prevents validation errors when optional fields receive empty strings from environment variables. This is particularly useful for optional URLs, numbers, and other validated fields.

    // Environment: SENTRY_URL=""
    const dynamicEnv = createDynamicEnv({
      schema: z.object({
        SENTRY_URL: z.string().url().optional(), // Would fail without this feature
      }),
      client: {
        SENTRY_URL: process.env.SENTRY_URL, // "" becomes undefined
      },
      server: {},
      // emptyStringAsUndefined: true (default)
    });
    
    // Result: dynamicEnv.SENTRY_URL === undefined ✅

    This matches the behavior of popular libraries like T3 Env and provides better developer experience. The option can be disabled by setting emptyStringAsUndefined: false.

[email protected]

20 Aug 16:16
c127509

Choose a tag to compare

Patch Changes

  • 6228e74 Thanks @ReesMorris! - Fix README not appearing on npm by replacing symlink with actual file