Skip to content

feat(platform): @base44/platform/react, option A: the hook only - #315

Draft
amitbardos wants to merge 4 commits into
mainfrom
amitb/platform-react-hook-only
Draft

amitbardos wants to merge 4 commits into
mainfrom
amitb/platform-react-hook-only

Conversation

@amitbardos

@amitbardos amitbardos commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Option A of two. This PR ships only the hook. base44/javascript-sdk#314 is option B: the same hook plus a provider and replaceable parts. Only one of the two will be merged.

Start here: examples/react-chat/ is Tiny Sunny's chat rebuilt on this option: Chat.tsx is the chat, chatParts.tsx its look, server.ts the four backend calls. It imports the package from the workspace, so the diff there is only new files.

What

A new subpath of the platform package, @base44/platform/react, with one hook: useBase44Chat. It runs a white-label builder chat for one app on top of the existing client and renders nothing. The partner draws everything.

import { useBase44Chat } from "@base44/platform/react";

const chat = useBase44Chat({ appId, server, onAppCreated });
// chat.items, chat.phase, chat.error, chat.canSend, chat.send(), chat.create(), chat.clearError()
  • Items made for rendering. chat.items is the conversation, oldest first: role, text, steps (one per tool call) and, while the builder waits, a question.
  • Questions bound to their actions. A question is a union on kind (choice, input, approval, unknown) and carries only the actions its kind allows, each bound to its own tool call. A component can only answer the question it renders, also when several are open.
  • server: four calls the partner implements, in any language behind them (createApp, openLiveSession, sendMessage, submitToolCallInput). No credential reaches the browser.
  • phase and error instead of pre-worded status text; canSend is false while a question is open, because Base44 drops a message sent into a stopped turn.
  • Actions never throw. A failure lands in error; a question whose reply failed opens again.

Packaging

  • exports["./react"] plus typesVersions for node10 resolution.
  • react is an optional peer; the root entry does not import it. The tarball test asserts it is never a dependency.
  • React, react-dom, their types and jsdom are devDependencies, for the hook tests only.

Where it comes from

The engine of the headless chat library prototyped in base44/base44-platform-starter#64 (Tiny Sunny), after Ronny's review there: bound question actions, send/create split, { phase, error }, explicit public types, server behind a ref.

Tests

  • tests/unit/react/chat-items.test.ts: the message-to-items mapping, without React.
  • tests/unit/react/useBase44Chat.test.ts: the hook under jsdom with a recorded platform client.
  • tests/types/react.types.ts and examples/react-chat/: compile against the subpath, JSX included.
  • tests/package.test.mjs: the published /react entry resolves at runtime and under NodeNext, Bundler and Node resolution.

🤖 Generated with Claude Code

amitbardos and others added 2 commits October 10, 2026 19:47
…der chat

One React hook, useBase44Chat, on a new subpath of the platform package. It opens
the live session through the client, turns messages into items made for rendering,
and binds every question the builder asks to the actions that answer it, typed per
kind, so a component can only answer the question it renders. It renders nothing.

React is an optional peer, loaded only by the /react entry; the root entry stays
framework-free. The four Base44 calls come from a server object the partner
implements, so no credential reaches the browser.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
The lockfile entries for react, react-dom, their types and jsdom pointed at an
internal registry mirror that CI cannot reach, so `npm ci` failed in every job.
Same versions, resolved from registry.npmjs.org like the rest of the lockfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

🚀 Package Preview Available!


Install this PR's preview build with npm:

npm i @base44-preview/sdk@0.8.53-pr.315.6bdf6db

Prefer not to change any import paths? Install using npm alias so your code still imports @base44/sdk:

npm i "@base44/sdk@npm:@base44-preview/sdk@0.8.53-pr.315.6bdf6db"

Or add it to your package.json dependencies:

{
  "dependencies": {
    "@base44/sdk": "npm:@base44-preview/sdk@0.8.53-pr.315.6bdf6db"
  }
}

Preview published to npm registry — try new features instantly!

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>
…ned example

examples/react-chat/ replaces the single-file example: the chat (Chat.tsx), its
parts (chatParts.tsx) and the four server functions (server.ts), with a README
saying what to read first. It imports @base44/platform/react from the workspace,
so it needs no copy of the package, and the type tests check it, JSX included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@amitbardos
amitbardos force-pushed the amitb/platform-react-hook-only branch from 51bc094 to 17c2d1a Compare October 10, 2026 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant