[PR #4360] [MERGED] fix: prevent build error for node:sqlite #13576

Closed
opened 2026-04-13 09:00:46 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/better-auth/better-auth/pull/4360
Author: @bytaesu
Created: 9/2/2025
Status: Merged
Merged: 9/2/2025
Merged by: @himself65

Base: canaryHead: fix/node-sqlite-build-error


📝 Commits (1)

  • e3300b9 fix: prevent build error for node:sqlite

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 packages/better-auth/src/adapters/kysely-adapter/dialect.ts (+1 -1)

📄 Description


This PR fixes build errors caused by importing node:sqlite.

  • Wraps the import in a server-only guard (typeof window === "undefined")

Build error:

"next": "^15.5.2"
"better-auth": "1.3.8-beta.10"
build-error import-trace

NOTE: Even in beta/development, I want build errors to be caught early.

I have been developing to use the Kakao Provider, and just before deployment, the production build was failing unexpectedly. After investigation, it seems this issue was the cause.


Summary by cubic

Fixes production build errors by restricting node:sqlite usage to the server in the Kysely adapter. Adds a typeof window === "undefined" guard so client bundles don’t import node:sqlite during Next.js builds.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/better-auth/better-auth/pull/4360 **Author:** [@bytaesu](https://github.com/bytaesu) **Created:** 9/2/2025 **Status:** ✅ Merged **Merged:** 9/2/2025 **Merged by:** [@himself65](https://github.com/himself65) **Base:** `canary` ← **Head:** `fix/node-sqlite-build-error` --- ### 📝 Commits (1) - [`e3300b9`](https://github.com/better-auth/better-auth/commit/e3300b9994312f89ce85ef7395ac393f41239bef) fix: prevent build error for node:sqlite ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `packages/better-auth/src/adapters/kysely-adapter/dialect.ts` (+1 -1) </details> ### 📄 Description --- This PR fixes build errors caused by importing node:sqlite. - Wraps the import in a server-only guard (`typeof window === "undefined"`) --- **Build error:** ``` "next": "^15.5.2" "better-auth": "1.3.8-beta.10" ``` <img width="500" alt="build-error" src="https://github.com/user-attachments/assets/e0c60428-51ab-4737-8eb6-d25ca12d2220" /> <img width="500" alt="import-trace" src="https://github.com/user-attachments/assets/ab799d56-66f8-4493-b281-3569bd346119" /> --- > **NOTE: Even in beta/development, I want build errors to be caught early.** > > I have been developing to use the Kakao Provider, and just before deployment, the production build was failing unexpectedly. After investigation, it seems this issue was the cause. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Fixes production build errors by restricting node:sqlite usage to the server in the Kysely adapter. Adds a typeof window === "undefined" guard so client bundles don’t import node:sqlite during Next.js builds. <!-- End of auto-generated description by cubic. --> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-13 09:00:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#13576