From fba24f9be8fbc59c43dcfa1ea53f0bf552cde820 Mon Sep 17 00:00:00 2001 From: Thorben <38816229+tklein1801@users.noreply.github.com> Date: Fri, 25 Apr 2025 16:59:07 +0200 Subject: [PATCH] chore: Add ExpressJS v5 implementation disclaimer --- docs/content/docs/installation.mdx | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/content/docs/installation.mdx b/docs/content/docs/installation.mdx index 0fcee8f337..2ea3cff6ce 100644 --- a/docs/content/docs/installation.mdx +++ b/docs/content/docs/installation.mdx @@ -302,6 +302,18 @@ Better Auth supports any backend framework with standard Request and Response ob + + ExpressJS v5 introduced breaking changes to route path matching by switching to `path-to-regexp@6`. Wildcard routes like `*` should now be written using the new named syntax, e.g. `/{*any}`, to properly capture catch-all patterns. This ensures compatibility and predictable behavior across routing scenarios. + See the [Express v5 migration guide](https://expressjs.com/en/guide/migrating-5.html) for details. + + As a result, the implementation in ExpressJS v5 should look like this: + + ```ts + app.all('/api/auth/{*any}', toNodeHandler(auth)); + ``` + *The name any is arbitrary and can be replaced with any identifier you prefer.* + + ```ts title="server.ts" import express from "express"; import { toNodeHandler } from "better-auth/node";