Node-sdk use on react-native

I need to add support deep link for concordium wallet on react native, based on already written libraries.
I was suggested to try the idea:
Since the interfaces of @concordium/web-sdk and @concordium/node-sdk are identical, just use the already written library @concordium/react-components and @concordium/wallet-connectors and just replace the imports from @concordium/web-sdk with @concordium/node-sdk.

In the process of using @concordium/node-sdk I came across this error:

If I understand correctly, the problem is that there is no required library (module), but I can’t find such a thing either within the library or in npm


My actions:

What kind of error do you get if you don’t replace the imports of @concordium/web-sdk with @concordium/node-sdk?

The SDK’s are built specifically for the nodeJS and browser platforms, and we haven’t tested either on react native.

To work around the specific error, you could try to get your build configuration to resolve crypto to, but I cannot guarantee that you won’t hit another error pertaining to the SDK targeting a specific platform.

Here is a reference to documentation regarding npm modules and compatibility with react-native:
Using Libraries · React Native.

Best of luck!


Thanks for the tips!
If I don’t replace the libraries and just copy the code, I get an error with @react-native-async-storage/async-storage.
The result is the same if I don’t copy the code, but do an import from the library.

After installing the react-native-crypto module and replacing the following line in node_modules
replace to const crypto = __importStar(require("crypto"));
replace to const crypto = __importStar(require("react-native-crypto"));
A new error appears with the fs module

I tried to install it too (although it should have been installed. Then I got a message like this

What happens if you install the missing dependency, i.e. @react-native-async-storage/async-storage?

All of these errors happen because we do not support react-native with our SDK. The best advice I can give is to just try to go through the errors as they come and install whichever missing dependency it complains about.

1 Like

I still think you should use @concordium/web-sdk instead of @concordium/node-sdk, as I suspect that will cause the least problems. I have to re-iterate though, that none of these are supposed to support react-native, so it’s up to you to provide the missing compatibility components.

1 Like