Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(platform/react): mark the hook and context modules "use client"
Next.js App Router treats a module without the directive as a server module, so
rendering the provider (or calling the hook) from a server component fails. The
modules that use hooks or context now carry it, and the tarball test checks the
compiled output keeps it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
amitbardos and claude committed Oct 10, 2026
commit 2b1aebdf0a848f1085db7fbeaacbfb0d9f376788
1 change: 1 addition & 0 deletions packages/platform/src/react/Base44ChatProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useMemo } from "react";
import type { Base44ChatProviderProps, ChatComponents } from "./components.types.js";
import { ActionsContext, ComponentsContext, StateContext } from "./context.js";
Expand Down
1 change: 1 addition & 0 deletions packages/platform/src/react/Message.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import type { MessageProps, QuestionProps } from "./components.types.js";
import { useChatComponents } from "./context.js";

Expand Down
1 change: 1 addition & 0 deletions packages/platform/src/react/context.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { createContext, useContext } from "react";
import type { ChatActions, ChatComponents, ChatState } from "./components.types.js";
import { fallbackComponents } from "./fallbacks.js";
Expand Down
1 change: 1 addition & 0 deletions packages/platform/src/react/fallbacks.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useId, useState } from "react";
import type { ChatComponents, StepProps, TextProps } from "./components.types.js";
import type { ApprovalQuestion, ChoiceQuestion, InputQuestion, UnknownQuestion } from "./chat.types.js";
Expand Down
1 change: 1 addition & 0 deletions packages/platform/src/react/useBase44Chat.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"use client";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import { Base44PlatformClient } from "../client.js";
import type { ChatMessage } from "../modules/builder.events.types.js";
Expand Down
6 changes: 6 additions & 0 deletions packages/platform/tests/package.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@ test("the client resolves from the installed package without the runtime SDK", (
`]);
});

test("the React modules that use hooks or context keep their \"use client\" directive", () => {
for (const file of ['dist/react/useBase44Chat.js', 'dist/react/context.js', 'dist/react/Base44ChatProvider.js', 'dist/react/Message.js', 'dist/react/fallbacks.js']) {
assert.match(readFileSync(path.join(installed, file), "utf8"), /^"use client";/, file);
}
});

test("react is an optional peer of the /react entry, never a dependency of the client", () => {
assert.equal("react" in manifest.dependencies, false);
assert.deepEqual(manifest.peerDependencies, { react: "^18.0.0 || ^19.0.0" });
Expand Down
Loading