Skip to content

Commit 7c2c3d9

Browse files
fix(cli): update ai sdk example for nextjs
1 parent a27e305 commit 7c2c3d9

File tree

4 files changed

+20
-4
lines changed

4 files changed

+20
-4
lines changed

apps/cli/src/constants.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export const dependencyVersionMap = {
113113
"@ai-sdk/vue": "^2.0.39",
114114
"@ai-sdk/svelte": "^3.0.39",
115115
"@ai-sdk/react": "^2.0.39",
116-
streamdown: "^1.2.0",
116+
streamdown: "^1.3.0",
117+
shiki: "^3.12.2",
117118

118119
"@orpc/server": "^1.8.6",
119120
"@orpc/client": "^1.8.6",
@@ -151,7 +152,7 @@ export const dependencyVersionMap = {
151152
"@sveltejs/adapter-cloudflare": "^7.2.1",
152153
"@cloudflare/workers-types": "^4.20250822.0",
153154

154-
alchemy: "^0.65.1",
155+
alchemy: "^0.67.0",
155156
// temporary workaround for alchemy + tanstack start
156157
nitropack: "^2.12.4",
157158

apps/cli/src/helpers/addons/examples-setup.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export async function setupExamples(config: ProjectConfig) {
3232
frontend.includes("tanstack-router") ||
3333
frontend.includes("next") ||
3434
frontend.includes("tanstack-start");
35+
const hasNext = frontend.includes("next");
3536
const hasReactNative =
3637
frontend.includes("native-nativewind") ||
3738
frontend.includes("native-unistyles");
@@ -45,6 +46,11 @@ export async function setupExamples(config: ProjectConfig) {
4546
} else if (hasReactWeb) {
4647
dependencies.push("@ai-sdk/react", "streamdown");
4748
}
49+
50+
if (hasNext) {
51+
dependencies.push("shiki");
52+
}
53+
4854
await addPackageDependency({
4955
dependencies,
5056
projectDir: webClientDir,

apps/cli/templates/examples/ai/web/react/next/src/app/ai/page.tsx.hbs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,16 @@
33
import { useChat } from "@ai-sdk/react";
44
import { DefaultChatTransport } from "ai";
55
import { Send } from "lucide-react";
6+
{{#if (or (eq webDeploy "wrangler") (eq webDeploy "alchemy"))}}
67
import dynamic from "next/dynamic";
8+
{{else}}
9+
import { Response } from "@/components/response";
10+
{{/if}}
711
import { useEffect, useRef, useState } from "react";
812
import { Button } from "@/components/ui/button";
913
import { Input } from "@/components/ui/input";
1014

15+
{{#if (or (eq webDeploy "wrangler") (eq webDeploy "alchemy"))}}
1116
const Response = dynamic(
1217
() =>
1318
import("@/components/response").then((mod) => ({ default: mod.Response })),
@@ -20,6 +25,7 @@ const Response = dynamic(
2025
ssr: false,
2126
}
2227
);
28+
{{/if}}
2329

2430
export default function AIPage() {
2531
const [input, setInput] = useState("");
@@ -94,4 +100,4 @@ export default function AIPage() {
94100
</form>
95101
</div>
96102
);
97-
}
103+
}

apps/cli/templates/frontend/react/next/next.config.ts.hbs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,13 @@ import type { NextConfig } from "next";
55

66
const nextConfig: NextConfig = {
77
typedRoutes: true,
8+
{{#if (includes examples "ai")}}
9+
transpilePackages: ["shiki"],
10+
{{/if}}
811
};
912

1013
export default nextConfig;
1114

1215
{{#if (or (eq webDeploy "alchemy") (eq webDeploy "wrangler"))}}
1316
initOpenNextCloudflareForDev();
14-
{{/if}}
17+
{{/if}}

0 commit comments

Comments
 (0)