Skip to content

Choose a tag to compare

@github-actions github-actions released this 20 Aug 17:09
· 74 commits to main since this release
64f9e37

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.