neondatabase / neondatabase/serverless

Incompatibility with better-auth: @neondatabase/serverless requires tagged-template syntax, breaking drizzle-orm/neon-http integration

Open
#170 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
548
Forks
81
PR merge metrics
No merged PRs in 30d

Description

Hi Neon team,

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)

Steps to reproduce

1 - initialize db connection
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);
const db = drizzle({ client: sql, schema: authSchema });

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

Expected result

We expected @neon/serverless to be able to support the way pg driver and better-auth are calling the tagged-template function, since libraries who supports neon does not support Tagged-template composability since it's relatively new.

Environment / Packages involved

  • [1.0.1] @neondatabase/serverless
  • [0.38.4] drizzle-orm/neon-http
  • [1.3.4] better-auth/adapters/drizzle

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure with @neondatabase/serverless 1.0.1, drizzle-orm/neon-http 0.38.4, and better-auth 1.3.4. Start at the Neon client path around index.mjs:1276 and the Drizzle call at session.ts:68. Done means the shown better-auth integration can execute its conventional query calls without the tagged-template runtime error.

Written by the indexing model from the issue text.

Assessment

Tech stack
postgresql, sql, typescript
Domain
backend-api-design, databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.