Repository navigation
v4.0.2
Release Notes v4.0.2
This release introduces serverOnly() for safe isomorphic access to server secrets and modernizes dependency management with pnpm catalog.
π Highlights
β¨ New serverOnly() Function for Isomorphic Server Secrets
Access server-only environment variables without throwing in browser contexts. Unlike env(), the new serverOnly() function gracefully returns a fallback value when called from client code, enabling cleaner isomorphic patterns.
import { serverOnly } from 'next-dynenv'
// Returns actual value on server, fallback on client
const dbUrl = serverOnly('DATABASE_URL', 'postgresql://localhost:5432/dev')
const apiSecret = serverOnly('API_SECRET_KEY') // undefined on clientThis is particularly useful for shared configuration modules with lazy evaluation patterns using Zod schemas.
π¦ Centralized Dependency Versions with pnpm Catalog
Dependency versions are now centralized in pnpm-workspace.yaml using the catalog: protocol. This ensures consistent versions across the workspace and simplifies version bumps.
β¨ Features
-
serverOnly()function β New export insrc/script/env.tsthat reads non-public environment variables without throwing in browser contexts. Returns the fallback value whenwindowexists, readsprocess.envon the server. -
pnpm catalog support β All dependencies in
package.jsonandtest-app/package.jsonnow usecatalog:references pointing to versions defined inpnpm-workspace.yaml. -
nextmoved to devDependencies β Thenextpackage is only needed for development and testing, not as a runtime dependency of the published package.
π§ Improvements
-
pnpm version via
packageManagerfield β Upgraded to pnpm 10.26.0 and removed explicitPNPM_VERSIONenv variables from CI workflows. Thepnpm/action-setup@v4action automatically detects the version from thepackageManagerfield inpackage.json. -
Security override cleanup β Removed the
js-yamlsecurity override from pnpm config as the vulnerability in transitive dependencies has been resolved upstream. -
Security overrides for transitive deps β Added pnpm overrides for
glob(>=10.5.0) andbrace-expansion(>=2.0.2) to address security vulnerabilities.