Skip to content

Conversation

amrmelsayed
Copy link
Contributor

@amrmelsayed amrmelsayed commented Jun 9, 2025

@mme I am trying to run the typescript-sdk in a React Native / Expo environment using the Metro bundler, I got a build error due to the package's reliance on crypto:

The package at "apps/dojo-rn/node_modules/@ag-ui/langgraph/dist/index.js" attempted to import the Node standard library module "crypto".
It failed because the native React runtime does not include the Node standard library.

I am currently employing a polyfill using expo-standard-web-crypto combined with a package patch to resolve this issue, here is a sample of the patch I am currently using @ag-ui+langgraph+0.0.1-alpha.0.patch

It basically replaces the ot=require("crypto") with ot={randomUUID:()=>global.crypto.randomUUID()} that is supplied via a polyfill.

This PR basically replaces the direct crypto imports and function calls with UUID v11 which is already an existing dependency, this can then be combined with expo-standard-web-crypto in React Native / Expo projects to provide the required polyfill without additional patches https://github.com/expo/expo/tree/main/packages/expo-standard-web-crypto.

Fixes #79.

@amrmelsayed amrmelsayed marked this pull request as draft June 13, 2025 06:33
@amrmelsayed
Copy link
Contributor Author

amrmelsayed commented Jun 13, 2025

@mme Thanks a lot for your time today, I had another look at the RN client implementation, I don't think we need this patch in particular as these dependencies are expected to run server side, I think this is probably an issue on my end as I set up a combined React Native project that uses AG-UI in mobile app mode (Android, iOS) and CopilotKit in React Native Web, I think the issue is in CopilotKit, don't worry about this PR for now, I think we just need to update CopilotKit's uuid dependency to version 11 to work around an issue related to mixing commonjs and ESM modules, I will have a look and follow-up.

@tylerslaton
Copy link
Contributor

Hi @amrmelsayed this is actually something we would like to merge because you're pushing up against something we'd want.

It's actually an issue for the other way around - this code cannot run in the browser because of the node:crypto. Would you mind rebasing so we can get this merged?

@maxkorp
Copy link
Contributor

maxkorp commented Oct 13, 2025

I hope you don't mind @amrmelsayed, I rebased this and updated it to be current and pushed it up to your branch, since you had that enabled.

@maxkorp maxkorp merged commit 7308923 into ag-ui-protocol:main Oct 13, 2025
21 checks passed
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.

React Native Crypto Dependency Error

3 participants