Skip to content

React Native example - #334

Merged
abhithesys merged 6 commits into
mainfrom
abhishek/react-native
Mar 14, 2026
Merged

React Native example#334
abhithesys merged 6 commits into
mainfrom
abhishek/react-native

Conversation

@abhithesys

Copy link
Copy Markdown
Contributor

Screen.Recording.2026-03-14.at.5.45.44.PM.mov

Comment thread docs/content/docs/openui-lang/examples/react-native.mdx
Comment thread docs/content/docs/openui-lang/examples/react-native.mdx

This file mirrors the mobile library, but every `component` returns `null`. That lets the OpenUI CLI inspect the component definitions in a Node environment and generate `system-prompt.txt` without importing React Native.

Run `pnpm generate:prompt` any time you change:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given that we are already duplicating the types - do we need this?
cant we directly call library.toPrompt() on the backend in nextjs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

facing react-version mismatch issue in next. tried building it outside of pnpm-package, issue remained. we either ways need to fix the approach


### `backend/src/library.ts` - Node-compatible prompt source

This file mirrors the mobile library, but every `component` returns `null`. That lets the OpenUI CLI inspect the component definitions in a Node environment and generate `system-prompt.txt` without importing React Native.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we have a common file that both backend and react-native imports that just has the zod types rather than duplicating it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cli isn't working with react-native components and importing in next is also broken at the moment.

root: "Card",
});

export const promptOptions: PromptOptions = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? Doesn't the toPrompt already handle this

import { library } from "../library";
import { useStreamContent } from "../store/streamStore";

export function BotBubble({ messageId }: { messageId: string }) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would it be better to call this AssistantBubble & AssistantMessage throughout rather than calling it Bot to keep it consistent with other examples

// ─── Message types ────────────────────────────────────────────────────────────

type UserMessage = { id: string; type: "user"; text: string };
type BotMessage = { id: string; type: "bot" };

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment: Assistant rather than Bot

"android": {
"adaptiveIcon": {
"backgroundColor": "#E6F4FE",
"foregroundImage": "./assets/android-icon-foreground.png",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add the iOS images and/or remove the android ones

Comment thread docs/content/docs/openui-lang/examples/react-native.mdx
@abhithesys
abhithesys merged commit f7425fe into main Mar 14, 2026
2 checks passed
@abhithesys
abhithesys deleted the abhishek/react-native branch March 14, 2026 13:06
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.

2 participants