Skip to content

v3: boolean in .env resolves to string #3839

Closed

Description

@MickL

Environment

Nitro: 3.0.1-alpha.1
Bun: 1.3.3

Reproduction

https://github.com/MickL/nitro-env-boolean

Describe the bug

I noticed that when using booleans in runtiemConfig it works:

export default defineConfig({
    serverDir: "./",
    runtimeConfig: {
        a: false,
        b: false,
    }
});

But when they get overwritten from .env they become a string:

.env

NITRO_B=false

handler

import {defineHandler} from "nitro/h3";
import {useRuntimeConfig} from "nitro/runtime-config";

export default defineHandler((event) => {
    const config = useRuntimeConfig();

    return {
        a: config.a, // boolean
        b: config.b, // string
    }
});

Activity

  1. added
    pending triage
    on Dec 5, 2025
  2. MickL commented on Dec 5, 2025

    @MickL
    ContributorAuthor

    I guess that depends on what library is used to parse the env file, some do parse to string, number, boolean, array.

    Btw. I dont think the Node docs are a good reference since Node is more the exception than the standard.

  3. kricsleo commented on Dec 6, 2025

    @kricsleo
    Member

    I guess that depends on what library is used to parse the env file

    It's dotenv.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    pending triage

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions