+ typeof window !== "undefined"
+ ? (process.env.NEXT_PUBLIC_BASE_URL || window.location.origin)
+ : (process.env.BASE_URL || "http://localhost:3000");
+
export default function ChatModal() {
const router = useRouter();
+ const baseURL = getBaseURL();
return (
{/* Backdrop */}
router.back()}>
@@ -656,7 +679,7 @@ export default function ChatModal() {
{/* Panel is pre-opened; no trigger button rendered */}
{
@@ -823,7 +846,7 @@ The default `ToolCallDisplay` component shows:
Provide custom UI components for specific tools using the `toolRenderers` override. Each key should match the tool name from your backend configuration:
-```tsx title="app/pages/[[...all]]/layout.tsx"
+```tsx title="app/pages/layout.tsx"
import type { AiChatPluginOverrides, ToolCallProps } from "@btst/stack/plugins/ai-chat/client"
// Custom weather card component
@@ -978,6 +1001,8 @@ By default, public mode is completely stateless - messages are lost on page refr
import { ChatLayout, type UIMessage } from "@btst/stack/plugins/ai-chat/client";
import { useLocalStorage } from "@/hooks/useLocalStorage"; // Your hook
+const baseURL = typeof window !== "undefined" ? window.location.origin : "http://localhost:3000";
+
export default function PublicChat() {
const [messages, setMessages] = useLocalStorage(
"public-chat-messages",
@@ -986,7 +1011,7 @@ export default function PublicChat() {
return (
Date: Tue, 10 Mar 2026 19:17:09 -0400
Subject: [PATCH 4/5] fix: change AI chat mode from authenticated to public in
layout and stack
---
demos/ai-chat/app/pages/layout.tsx | 2 +-
demos/ai-chat/lib/stack.ts | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/demos/ai-chat/app/pages/layout.tsx b/demos/ai-chat/app/pages/layout.tsx
index d72513ab..5060f63c 100644
--- a/demos/ai-chat/app/pages/layout.tsx
+++ b/demos/ai-chat/app/pages/layout.tsx
@@ -36,7 +36,7 @@ export default function PagesLayout({
"ai-chat": {
apiBaseURL: baseURL,
apiBasePath: "/api/data",
- mode: "authenticated",
+ mode: "public",
navigate: (path) => router.push(path),
refresh: () => router.refresh(),
Link: ({ href, ...props }) => (
diff --git a/demos/ai-chat/lib/stack.ts b/demos/ai-chat/lib/stack.ts
index c822a8f6..ccdf18f1 100644
--- a/demos/ai-chat/lib/stack.ts
+++ b/demos/ai-chat/lib/stack.ts
@@ -19,7 +19,7 @@ function createStack() {
plugins: {
aiChat: aiChatBackendPlugin({
model,
- mode: "authenticated",
+ mode: "public",
systemPrompt:
"You are a helpful assistant in the BTST AI Chat demo. Help users explore the BTST framework and its plugins.",
}),
From 0a2fdd558018efc277c8b10232f8db5a4066bc8a Mon Sep 17 00:00:00 2001
From: olliethedev <3martynov@gmail.com>
Date: Wed, 11 Mar 2026 10:37:48 -0400
Subject: [PATCH 5/5] fix: update AI chat mode to public in stack-client
configuration
---
demos/ai-chat/lib/stack-client.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/demos/ai-chat/lib/stack-client.ts b/demos/ai-chat/lib/stack-client.ts
index bc8cb513..55cdf7a9 100644
--- a/demos/ai-chat/lib/stack-client.ts
+++ b/demos/ai-chat/lib/stack-client.ts
@@ -26,7 +26,7 @@ export const getStackClient = (
apiBasePath: "/api/data",
siteBaseURL: baseURL,
siteBasePath: "/pages",
- mode: "authenticated",
+ mode: "public",
}),
routeDocs: routeDocsClientPlugin({
queryClient,