Skip to content

Commit d5bf033

Browse files
authored
Merge pull request #295 from better-stack-ai/upgrade/stable-frameworks-20261028
feat: upgrade stable frameworks and migrate AI SDK 7
2 parents 63f08c6 + 295823f commit d5bf033

85 files changed

Lines changed: 8369 additions & 10459 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/actions/pack-auth-ui/action.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ runs:
1111
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
1212
with:
1313
repository: better-stack-ai/better-auth-ui
14-
ref: 48ebf19cc598654e5a06296e808eb376c55a236a # Published 3.0.1 companion
14+
ref: 8d4fc633f75defd06bfbef180ba4968ee316b0dd # Upstream 1.7.32; Auth 1.7.14 / Stack 5 compatibility
1515
path: .packed-consumer/better-auth-ui
1616
- name: Install and build Better Auth UI
1717
shell: bash

‎.github/workflows/release.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fetch-depth: 0
3333
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
3434
with:
35-
node-version: 22.22.1
35+
node-version: 22.23.4
3636
- name: Verify exact release commit CI and deployments
3737
env:
3838
GH_TOKEN: ${{ github.token }}
@@ -65,7 +65,7 @@ jobs:
6565

6666
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
6767
with:
68-
node-version: 22.22.1
68+
node-version: 22.23.4
6969
registry-url: 'https://registry.npmjs.org'
7070

7171
- name: Install npm with trusted publishing support

‎.nvmrc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
22.18.0
1+
22.23.4
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Preserve UI primitives during framework upgrades
2+
3+
BTST's shared UI and generated application fixtures use Radix, while the playground uses Base UI. Keep those choices during framework and shadcn upgrades, reviewing upstream component changes while preserving existing APIs, behavior, and local customizations. Moving the shared components to Base UI would require a separate migration of component APIs and composition; [shadcn continues to support Radix](https://ui.shadcn.com/docs/changelog/2026-07-base-ui-default).
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Serve TanStack builds with a stable Node server
2+
3+
Use TanStack Start's standard Vite output with stable `srvx` for codegen test servers and playground exports. Nitro 3 is still a prerelease, and its bundling previously required BTST to pin an older TanStack/Vite toolchain; keeping that dependency conflicts with the stable-release policy for this upgrade. Serve `/uploads/` from the writable `public` directory with a terminal 404 for missing files so that build-time copies cannot restore deleted uploads, and serve other static files from `dist/client` before delegating to the TanStack fetch handler.
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Align AI and Auth dependency cohorts
2+
3+
Upgrade the optional AI plugin to AI SDK 7 with `@ai-sdk/react` 4 and matching
4+
provider packages. This removes the AI SDK 5 dependency on Undici 5. Keep BTST's
5+
`systemPrompt` configuration, pass it as SDK instructions, and reject caller
6+
system/data messages before model execution. Keep existing history authorization,
7+
identity partitioning, transaction guards, and client tool execution behavior.
8+
Reconstruct each tool step from the SDK's initial and response messages before
9+
reapplying compaction, because SDK 7 carries message overrides into later steps.
10+
The AI plugin now requires Node 22; the current React 19, Next 15+, and React Router 7+ consumer contracts remain.
11+
12+
Upgrade the DB/adapters/CLI together to the stable 3.0.1 patch prepared against
13+
published Better Auth/core 1.7.14 and utils 0.5.1. The published 3.0.0 packages pin
14+
Auth 1.7.6 exactly, so overriding their peers would not be a supported upgrade.
15+
The aligned patch also refreshes the vendored adapter fixes from upstream's exact
16+
stable tag and preserves BTST's memory transaction Date comparison patch.
17+
18+
The DB patch is prepared in the Auth fork and must be published before this
19+
BTST dependency change can be installed from the public registry. Local validation
20+
uses the packed release artifacts. Review database schema/index migrations before
21+
applying them in existing applications.
22+
23+
The Auth fork also fixes session-list pagination introduced in upstream 1.7.14.
24+
This fix affects the configuration combining secondary storage with
25+
`session.storeSessionInDatabase: true` and without
26+
`session.preserveSessionInDatabase: true`. The DB packages depend on official npm
27+
Better Auth, so publishing them does not ship this fork-only Auth fix. Avoid that
28+
configuration until the official package includes the correction; the default
29+
database session configuration is unaffected.
30+
31+
The workspace pins the typography plugin's selector parser to patched 6.1.5 for
32+
[GHSA-rj75-hqrm-r3gf](https://github.com/advisories/GHSA-rj75-hqrm-r3gf).
33+
Two low-severity upstream findings remain: `rehype-katex` still requires KaTeX
34+
0.16, while the [KaTeX fix](https://github.com/advisories/GHSA-238p-pmpm-9mq7)
35+
starts at 0.18.2; `unbuild`'s Rollup resolver uses `deepmerge`, which has
36+
[no patched release](https://github.com/advisories/GHSA-gcqx-w48m-w2h4).
37+
Do not force a different KaTeX major or replace the build system in this upgrade.

‎docs/content/docs/cli.mdx‎

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,17 @@ BTST has two CLI packages:
1313
- `@btst/cli` owns low-level DB schema generation and migrations
1414

1515
`@btst/codegen generate` and `@btst/codegen migrate` run the aligned
16-
`@btst/cli@3.0.0` release in isolation. This avoids adding its dependency graph
16+
`@btst/cli@3.0.1` release in isolation. This avoids adding its dependency graph
1717
or competing `btst` binary to the application. The delegated CLI still loads
1818
the configuration, environment files, aliases, Better Auth adapter, and ORM
1919
peers from the application directory.
2020

2121
## Init (Codegen)
2222

23-
Use `init` to scaffold BTST into an existing Next.js (App Router), React Router v7, or TanStack Start project:
23+
Use `init` to scaffold BTST into an existing Next.js (App Router), React Router v7/v8, or TanStack Start project.
24+
25+
React Router v8 requires Node.js 22.22+ and React / React DOM 19.2.7+.
26+
React Router v7 remains supported with BTST’s existing React 19 consumer requirements.
2427

2528
```bash
2629
npx @btst/codegen init
@@ -71,7 +74,7 @@ npx @btst/codegen migrate --config=lib/stack.ts --database-url=postgres://...
7174
```
7275

7376
When a delegated command fails, fix the underlying issue and run the equivalent
74-
`npx @btst/cli@3.0.0 ...` command directly.
77+
`npx @btst/cli@3.0.1 ...` command directly.
7578

7679
## About Better DB
7780

@@ -83,7 +86,7 @@ For v3 applications, prefer the codegen passthrough commands above. If a v2
8386
application lists `@btst/cli` in its dependencies, remove it during migration;
8487
the pinned one-off CLI keeps Better DB dependencies from polluting the consumer
8588
graph. You can still invoke the low-level CLI directly with
86-
`npx @btst/cli@3.0.0`.
89+
`npx @btst/cli@3.0.1`.
8790

8891
## Parameters
8992

@@ -101,13 +104,13 @@ Generate database schemas for your ORM from your BTST `dbSchema`:
101104
<Tabs items={["prisma", "drizzle", "kysely"]}>
102105
<Tab value="prisma">
103106
```bash
104-
npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=prisma --output=schema.prisma
107+
npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=prisma --output=schema.prisma
105108
```
106109
</Tab>
107110

108111
<Tab value="drizzle">
109112
```bash
110-
npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=drizzle --output=src/db/schema.ts
113+
npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=drizzle --output=src/db/schema.ts
111114
```
112115
</Tab>
113116

@@ -117,17 +120,17 @@ Generate database schemas for your ORM from your BTST `dbSchema`:
117120
**Using DATABASE_URL environment variable:**
118121

119122
```bash
120-
DATABASE_URL=sqlite:./dev.db npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql
123+
DATABASE_URL=sqlite:./dev.db npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql
121124
```
122125

123126
**Or using --database-url flag:**
124127

125128
```bash
126-
npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql --database-url=sqlite:./dev.db
129+
npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql --database-url=sqlite:./dev.db
127130
```
128131

129132
```bash
130-
npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql --database-url=postgres://user:pass@localhost:5432/db
133+
npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=kysely --output=migrations/schema.sql --database-url=postgres://user:pass@localhost:5432/db
131134
```
132135
</Tab>
133136
</Tabs>
@@ -140,25 +143,25 @@ Migrate your database schema directly (Kysely only). For Prisma and Drizzle, use
140143
**Using DATABASE_URL environment variable:**
141144

142145
```bash
143-
DATABASE_URL=sqlite:./dev.db npx @btst/cli@3.0.0 migrate --config=lib/stack.ts
146+
DATABASE_URL=sqlite:./dev.db npx @btst/cli@3.0.1 migrate --config=lib/stack.ts
144147
```
145148

146149
**Or using --database-url flag:**
147150

148151
```bash
149-
npx @btst/cli@3.0.0 migrate --config=lib/stack.ts --database-url=sqlite:./dev.db
152+
npx @btst/cli@3.0.1 migrate --config=lib/stack.ts --database-url=sqlite:./dev.db
150153
```
151154

152155
```bash
153-
npx @btst/cli@3.0.0 migrate --config=lib/stack.ts --database-url=postgres://user:pass@localhost:5432/db
156+
npx @btst/cli@3.0.1 migrate --config=lib/stack.ts --database-url=postgres://user:pass@localhost:5432/db
154157
```
155158

156159
### Generate SQL to File
157160

158161
Instead of running migrations directly, generate SQL to a file:
159162

160163
```bash
161-
npx @btst/cli@3.0.0 migrate --config=lib/stack.ts --output=migrations.sql --database-url=sqlite:./dev.db
164+
npx @btst/cli@3.0.1 migrate --config=lib/stack.ts --output=migrations.sql --database-url=sqlite:./dev.db
162165
```
163166

164167
## Project config loading
@@ -179,5 +182,5 @@ project context as the application:
179182
You can still override a value for one command:
180183

181184
```bash
182-
SOME_VAR=value npx @btst/cli@3.0.0 generate --config=lib/stack.ts --orm=prisma --output=schema.prisma
185+
SOME_VAR=value npx @btst/cli@3.0.1 generate --config=lib/stack.ts --orm=prisma --output=schema.prisma
183186
```

‎docs/content/docs/installation.mdx‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,21 @@ Or manually copy the [`SKILL.md`](https://github.com/better-stack-ai/better-stac
176176

177177
---
178178

179+
## Database and AI upgrades
180+
181+
Update `@btst/db`, your `@btst/adapter-*` package, and `@btst/cli` together to
182+
`3.0.1`. Their exact companion peers are `better-auth@1.7.14`,
183+
`@better-auth/core@1.7.14`, and `@better-auth/utils@0.5.1`. Remove overrides for older
184+
Auth versions. If your app uses Better Auth directly, review its 1.7 migration
185+
notes, regenerate your database schema, and review the resulting migrations
186+
before applying them. BTST's adapter helpers enable joins through
187+
`advanced.database.joins`; applications configuring Auth directly should use that
188+
option instead of `experimental.joins`.
189+
190+
AI Chat now uses AI SDK 7, `@ai-sdk/react` 4, and matching provider packages
191+
(OpenAI: `@ai-sdk/openai` 4). This optional plugin requires Node.js 22 or later;
192+
see the [AI Chat installation guide](/plugins/ai-chat).
193+
179194
## Manual installation
180195

181196
The steps below preserve the complete framework and adapter integration

‎docs/content/docs/meta.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"api-reference",
3434
"standalone-components",
3535
"shadcn-registry",
36+
"v5",
3637
"breaking-changes",
3738
"---[Play]Playground---",
3839
"[Try the Playground](https://www.better-stack.ai/playground)"

‎docs/content/docs/plugins/ai-chat.mdx‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@ import { PluginEvaluatorHeader } from "@/components/plugin-evaluator";
1515
Ensure you followed the general [framework installation guide](/installation) first.
1616
</Callout>
1717

18+
The AI plugin uses AI SDK 7 and requires Node.js 22 or later. Install a matching
19+
React wrapper and provider package:
20+
21+
```bash
22+
pnpm add ai@^7.0.155 @ai-sdk/react@^4.0.159 @ai-sdk/openai@^4.0.104
23+
```
24+
25+
Keep `systemPrompt` in your backend plugin configuration. BTST sends it through
26+
the SDK's `instructions` option; chat requests accept only `user` and `assistant`
27+
messages. Existing stored message records remain readable.
28+
29+
The default tool display recognizes approval and denied states. It does not
30+
approve tools automatically or provide approval controls; applications that use
31+
approval-required tools need their own approval flow. Existing page tools retain
32+
their configured execution behavior.
33+
34+
For custom SDK integrations, follow the [AI SDK 7 migration guide](https://ai-sdk.dev/docs/migration-guides/migration-guide-7-0).
35+
1836
Follow these steps to add the AI Chat plugin to your BTST setup.
1937

2038
### 1. Add Plugin to Backend API
@@ -88,7 +106,7 @@ const { handler, dbSchema } = createBackendStack({
88106
model: openai("gpt-4o"), // Or any LanguageModel from AI SDK
89107
access: "authorized", // Default; use "public" only intentionally
90108
systemPrompt: "You are a helpful assistant.", // Optional
91-
tools: {}, // Optional: AI SDK v5 tools
109+
tools: {}, // Optional: AI SDK 7 tools
92110
})
93111
},
94112
adapter: (db) => createMemoryAdapter(db)({})
@@ -379,10 +397,10 @@ inherits the stack's top-level `site` location.
379397

380398
- **Full-page Layout**: Responsive chat interface with collapsible sidebar
381399
- **Conversation Sidebar**: View, rename, and delete past conversations
382-
- **Streaming Responses**: Real-time streaming of AI responses using AI SDK v5
400+
- **Streaming Responses**: Real-time streaming of AI responses using AI SDK 7
383401
- **Markdown Support**: Full markdown rendering with code highlighting
384402
- **File Uploads**: Attach images, PDFs, and text files to messages
385-
- **Tools Support**: Use AI SDK v5 tools for function calling
403+
- **Tools Support**: Use AI SDK 7 tools for function calling
386404
- **Customizable Models**: Use any LanguageModel from the AI SDK
387405
- **Typed Authorization**: Reuse the same schema-backed rules for browser hints and authoritative server checks
388406
- **Localization**: Customize all UI strings
@@ -900,7 +918,7 @@ aiChat: aiChatBackendPlugin({
900918

901919
### Adding Tools
902920

903-
Use AI SDK v5 tools for function calling:
921+
Use AI SDK 7 tools for function calling:
904922

905923
```ts title="lib/stack.ts"
906924
import { tool } from "ai"

0 commit comments

Comments
 (0)