[GH-ISSUE #3678] Incompatibility with better-auth: @neondatabase/serverless requires tagged-template syntax, breaking drizzle-orm integration with dri #18314

Closed
opened 2026-04-15 16:44:25 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @Kakhi74 on GitHub (Jul 28, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/3678

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Create a hono backend
  2. generate an auth drizzle schema
  3. initialize db connection
  4. initialize better-auth with the drizzle-adapter

Current vs. Expected behavior

Source:
https://neon.com/blog/serverless-driver-ga

We tried to integrate the better-auth service to handle auth in our api, but we keep hitting this runtime error introduced to the 1.0.0 update of @neondatabase/serverless package. We are using drizzle-orm/neon-http as the orm for our database

Since betterAuth doesn't use Tagged-template composability in order to run their queries, whenever I hit an auth endpoint we receive the following error from the Neon client library:

[wrangler:inf] OPTIONS /api/auth/sign-up/email 204 No Content (10ms)
✘ [ERROR] # SERVER_ERROR:  Error: This function can now be called only as a tagged-template function: sql`SELECT ${value}`, not sql("SELECT $1", [value], options). For a conventional function call with value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options).

at templateFn
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/@neondatabase+serverless@1.0.1/node_modules/@neondatabase/serverless/index.mjs:1276:25)
      at NeonHttpPreparedQuery.execute
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/neon-http/session.ts:68:24)
      at null.<anonymous>
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/pg-core/query-builders/select.ts:1003:27)
      at Object.startActiveSpan
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/tracing.ts:27:11)
      at PgSelectBase.execute
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/pg-core/query-builders/select.ts:1002:17)
      at PgSelectBase.then
  (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/query-promise.ts:31:15)


[wrangler:inf] POST /api/auth/sign-up/email 500 Internal Server Error (17ms)

We expected @neon/serverless to be able to support the way better-auth is calling the tagged-template function since it works on regular pg driver. Instead we are not able to use the betterAuth package.

What version of Better Auth are you using?

1.3.4

Provide environment information

- OS: macos 15.5

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

Backend

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { neon, neonConfig } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import * as authSchema from "@/db/pg/schema/auth";

const sql = neon(connectionString);
db = drizzle({ client: sql, schema: authSchema });

export const auth = betterAuth({
  emailAndPassword: {  
    enabled: true
  },
  database: drizzleAdapter(db, {
    provider: "pg",
    schema: authSchema,
    usePlural: true,
  })
});

Additional context

I tested my reproduction on all latest release of the packages mentionned

Originally created by @Kakhi74 on GitHub (Jul 28, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/3678 ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Create a hono backend 2. generate an auth drizzle schema 3. initialize db connection 4. initialize better-auth with the drizzle-adapter ### Current vs. Expected behavior Source: https://neon.com/blog/serverless-driver-ga We tried to integrate the better-auth service to handle auth in our api, but we keep hitting this runtime error introduced to the 1.0.0 update of @neondatabase/serverless package. We are using drizzle-orm/neon-http as the orm for our database Since betterAuth doesn't use Tagged-template composability in order to run their queries, whenever I hit an auth endpoint we receive the following error from the Neon client library: ``` [wrangler:inf] OPTIONS /api/auth/sign-up/email 204 No Content (10ms) ✘ [ERROR] # SERVER_ERROR: Error: This function can now be called only as a tagged-template function: sql`SELECT ${value}`, not sql("SELECT $1", [value], options). For a conventional function call with value placeholders ($1, $2, etc.), use sql.query("SELECT $1", [value], options). at templateFn (file:///Users/.../JMS/IMM/node_modules/.pnpm/@neondatabase+serverless@1.0.1/node_modules/@neondatabase/serverless/index.mjs:1276:25) at NeonHttpPreparedQuery.execute (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/neon-http/session.ts:68:24) at null.<anonymous> (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/pg-core/query-builders/select.ts:1003:27) at Object.startActiveSpan (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/tracing.ts:27:11) at PgSelectBase.execute (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/pg-core/query-builders/select.ts:1002:17) at PgSelectBase.then (file:///Users/.../JMS/IMM/node_modules/.pnpm/drizzle-orm@0.38.4_@cloudflare+workers-types@4.20250430.0_@neondatabase+serverless@1.0._eb019f29a71876f37cfe38449d23157e/node_modules/src/query-promise.ts:31:15) [wrangler:inf] POST /api/auth/sign-up/email 500 Internal Server Error (17ms) ``` We expected @neon/serverless to be able to support the way better-auth is calling the tagged-template function since it works on regular pg driver. Instead we are not able to use the betterAuth package. ### What version of Better Auth are you using? 1.3.4 ### Provide environment information ```bash - OS: macos 15.5 ``` ### Which area(s) are affected? (Select all that apply) Backend ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { neon, neonConfig } from "@neondatabase/serverless"; import { drizzle } from "drizzle-orm/neon-http"; import { drizzleAdapter } from "better-auth/adapters/drizzle"; import * as authSchema from "@/db/pg/schema/auth"; const sql = neon(connectionString); db = drizzle({ client: sql, schema: authSchema }); export const auth = betterAuth({ emailAndPassword: { enabled: true }, database: drizzleAdapter(db, { provider: "pg", schema: authSchema, usePlural: true, }) }); ``` ### Additional context I tested my reproduction on all latest release of the packages mentionned
GiteaMirror added the locked label 2026-04-15 16:44:25 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jul 28, 2025):

Hi @Kakhi74! I'm Dosu and I’m helping the better-auth team.

The root cause is that @neondatabase/serverless v1.0.0+ only supports tagged-template syntax for SQL queries (e.g., sql\SELECT ${value}``), while the current better-auth drizzle-adapter (and Drizzle ORM) may still use function-call style queries, which triggers the runtime error you’re seeing. This is a breaking change in the Neon driver and not currently handled by better-auth or its drizzle-adapter. There are no existing tickets or documentation in better-auth that address this incompatibility yet, and the adapter does not enforce or guarantee the required syntax in its query construction [source].

As a workaround, you could use a different database driver (like the regular pg driver) until either Drizzle ORM or better-auth updates to support the new Neon requirements. Otherwise, adapting better-auth to work with @neondatabase/serverless v1.0.0+ would require changes in how queries are issued, likely upstream in Drizzle ORM or in the adapter itself [source].

Keep an eye on updates from better-auth, Drizzle ORM, and @neondatabase/serverless for future compatibility.

To reply, just mention @dosu.


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

<!-- gh-comment-id:3128509541 --> @dosubot[bot] commented on GitHub (Jul 28, 2025): <!-- Greeting --> Hi @Kakhi74! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> The root cause is that @neondatabase/serverless v1.0.0+ only supports tagged-template syntax for SQL queries (e.g., `sql\`SELECT ${value}\``), while the current better-auth drizzle-adapter (and Drizzle ORM) may still use function-call style queries, which triggers the runtime error you’re seeing. This is a breaking change in the Neon driver and not currently handled by better-auth or its drizzle-adapter. There are no existing tickets or documentation in better-auth that address this incompatibility yet, and the adapter does not enforce or guarantee the required syntax in its query construction [[source]](https://github.com/better-auth/better-auth/pull/29). As a workaround, you could use a different database driver (like the regular pg driver) until either Drizzle ORM or better-auth updates to support the new Neon requirements. Otherwise, adapting better-auth to work with @neondatabase/serverless v1.0.0+ would require changes in how queries are issued, likely upstream in Drizzle ORM or in the adapter itself [[source]](https://github.com/better-auth/better-auth/pull/29). Keep an eye on updates from better-auth, Drizzle ORM, and @neondatabase/serverless for future compatibility. <!-- 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/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/5093fb88-abd1-4af2-b637-9d6301d22ccf?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/3678)
Author
Owner

@himself65 commented on GitHub (Aug 1, 2025):

This is drizzle-orm bug https://github.com/drizzle-team/drizzle-orm/compare/0.40.0...0.40.1

You should bump the dizzle-orm version and should be fixed

<!-- gh-comment-id:3145245111 --> @himself65 commented on GitHub (Aug 1, 2025): This is drizzle-orm bug https://github.com/drizzle-team/drizzle-orm/compare/0.40.0...0.40.1 You should bump the dizzle-orm version and should be fixed
Author
Owner

@alexcroox commented on GitHub (Aug 21, 2025):

Note this bug is present in "drizzle-orm": "^1.0.0-beta.1-40d80bd"

Edit: fixed in 1.0.0-beta.1-84d9a79

<!-- gh-comment-id:3210458061 --> @alexcroox commented on GitHub (Aug 21, 2025): Note this bug is present in `"drizzle-orm": "^1.0.0-beta.1-40d80bd"` Edit: fixed in 1.0.0-beta.1-84d9a79
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#18314