Releases: ReesMorris/next-dynamic-env
[email protected]
Patch Changes
121609dThanks @ReesMorris! - Update dependencies
[email protected]
Patch Changes
7cd7b6dThanks @ReesMorris! - Update dependencies
[email protected]
Minor Changes
-
#19
70251b4Thanks @ReesMorris! - Add automatic build phase detection for Docker deployments- Skip validation during
next buildto 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-dynamicto 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.
- Skip validation during
[email protected]
Minor Changes
-
#16
0f042b0Thanks @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]
Patch Changes
b15ad02Thanks @ReesMorris! - Add publishConfig to enable npm provenance with OIDC
[email protected]
Major Changes
-
94fea55Thanks @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
createDynamicEnvfor defining type-safe environment configurationsDynamicEnvScriptcomponent for client-side injectionwaitForEnvutility 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]
Minor Changes
-
#11
6a22f62Thanks @ReesMorris! - feat: separate client and server environments for enhanced securityBreaking Changes:
createDynamicEnvnow returns{ clientEnv, serverEnv }instead of a singleenvobjectDynamicEnvScriptnow only acceptsClientEnvtype- 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 (
__isClientand__isServer) for compile-time type safety - Made
processEnvironmentVariablesa pure function - Removed duplicate key checking as environments are now separate
v0.1.0
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
waitForEnvscript (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
isBrowserutility (032e2d2) - Rename
createEnvtocreateDynamicEnv(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]
Minor Changes
-
5aed912Thanks @ReesMorris! - AddemptyStringAsUndefinedoption to automatically convert empty environment variable strings toundefinedThis 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]
Patch Changes
6228e74Thanks @ReesMorris! - Fix README not appearing on npm by replacing symlink with actual file