node:sqlite support breaks nextjs build #1883

Closed
opened 2026-03-13 09:10:32 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @ubinatus on GitHub (Sep 8, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Use the NextJS starter with better-auth
  2. Use Node v22.10.0 (LTS)
  3. Try building NextJS
  4. You will receive:
node:sqlite
Module build failed: UnhandledSchemeError: Reading from "node:sqlite" is not handled by plugins (Unhandled scheme).
Webpack supports "data:" and "file:" URIs by default.
You may need an additional plugin to handle "node:" URIs.

Current vs. Expected behavior

The sqlite support shouldn't break existing projects that are not opting-in for sqlite.

What version of Better Auth are you using?

1.3.8

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041",
    "release": "24.6.0",
    "cpuCount": 16,
    "cpuModel": "Apple M4 Max",
    "totalMemory": "128.00 GB",
    "freeMemory": "13.69 GB"
  },
  "node": {
    "version": "v22.19.0",
    "env": "development"
  },
  "packageManager": {
    "name": "npm",
    "version": "10.9.3"
  },
  "frameworks": [
    {
      "name": "next",
      "version": "15.5.2"
    },
    {
      "name": "react",
      "version": "^19.1.1"
    }
  ],
  "databases": null,
  "betterAuth": {
    "version": "7.0.0",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Client

Auth config (if applicable)

import { inferAdditionalFields, organizationClient, phoneNumberClient } from 'better-auth/client/plugins';
import { createAuthClient } from 'better-auth/react';

const authClient = createAuthClient({
  plugins: [
    inferAdditionalFields({
      user: {
        lastName: {
          type: 'string',
          required: true,
        },
      },
    }),
    phoneNumberClient(),
    organizationClient(),
  ],
});

Additional context

No response

Originally created by @ubinatus on GitHub (Sep 8, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Use the NextJS starter with better-auth 2. Use Node v22.10.0 (LTS) 3. Try building NextJS 4. You will receive: ``` node:sqlite Module build failed: UnhandledSchemeError: Reading from "node:sqlite" is not handled by plugins (Unhandled scheme). Webpack supports "data:" and "file:" URIs by default. You may need an additional plugin to handle "node:" URIs. ``` ### Current vs. Expected behavior The sqlite support shouldn't break existing projects that are not opting-in for sqlite. ### What version of Better Auth are you using? 1.3.8 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041", "release": "24.6.0", "cpuCount": 16, "cpuModel": "Apple M4 Max", "totalMemory": "128.00 GB", "freeMemory": "13.69 GB" }, "node": { "version": "v22.19.0", "env": "development" }, "packageManager": { "name": "npm", "version": "10.9.3" }, "frameworks": [ { "name": "next", "version": "15.5.2" }, { "name": "react", "version": "^19.1.1" } ], "databases": null, "betterAuth": { "version": "7.0.0", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Client ### Auth config (if applicable) ```typescript import { inferAdditionalFields, organizationClient, phoneNumberClient } from 'better-auth/client/plugins'; import { createAuthClient } from 'better-auth/react'; const authClient = createAuthClient({ plugins: [ inferAdditionalFields({ user: { lastName: { type: 'string', required: true, }, }, }), phoneNumberClient(), organizationClient(), ], }); ``` ### Additional context _No response_
GiteaMirror added the nextjs label 2026-03-13 09:10:32 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Sep 8, 2025):

This is a known issue with Better Auth 1.3.8 and Node.js 22.x: Webpack does not handle the node:sqlite scheme by default, which can cause build failures in Next.js projects—even if you aren't using SQLite. The fix is to upgrade to Better Auth version 1.3.9-beta.1 or later, which conditionally imports node:sqlite only when actually needed, preventing this error for projects not opting in to SQLite support [source] [source].

No additional configuration or workaround is recommended; upgrading Better Auth is the supported solution.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Sep 8, 2025): <!-- Answer --> This is a known issue with Better Auth 1.3.8 and Node.js 22.x: Webpack does not handle the `node:sqlite` scheme by default, which can cause build failures in Next.js projects—even if you aren't using SQLite. The fix is to upgrade to Better Auth version 1.3.9-beta.1 or later, which conditionally imports `node:sqlite` only when actually needed, preventing this error for projects not opting in to SQLite support [[source]](https://github.com/better-auth/better-auth/issues/4450) [[source]](https://github.com/better-auth/better-auth/pull/3869). No additional configuration or workaround is recommended; upgrading Better Auth is the supported solution. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/51572a24-c0cc-4e5f-8e0f-eb2e44a8e5b1?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/4523)
Author
Owner

@ubinatus commented on GitHub (Sep 8, 2025):

Seems resolved in better-auth@1.3.9-beta.4

@ubinatus commented on GitHub (Sep 8, 2025): Seems resolved in `better-auth@1.3.9-beta.4`
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1883