It works fine on pc browser, but it doesn't work on mobile web browser

When I was developing on pc, I didn’t know because there was no error. My team members have been struggling for 2 weeks. Please help.

I’m using @web3auth/modal using React Vite,
If you only enter the mobile web browser, the openlogin adapter does not work.
I also checked the version because I was afraid that it was not supported by the mobile browser (Safari, Chrome), but they were all the latest versions.

When I accessed the demo page (https://demo.web3auth.io/) provided by web3auth on my mobile
It worked well.
So I thought there was a problem with our code, so I looked for the error for a long time.
while GitHub - Web3Auth/web3auth-pnp-examples
I downloaded that code here and tried running both react-no-modal and react-modal, but I got the same error.
The error is
Unhandled Promise Rejection: TypeError: null is not an object (evaluating ‘import_crypto.default.createHash’
Ida.

How do I solve this? Please help me…

Please let me know the code of demopage (https://demo.web3auth.io/) ).
I’m worried about my poor English, but I hope it’s delivered well.

Hey @hyowon09877 welcome onboard. Thanks for the detailed ticket, we’ll try to reproduce it. Meanwhile, here’s the code of Web3Auth Demo.

Thank you so much!
I ran the demo code as ‘npm run dev – – host’ and tested both pc and mobile, and still mobile gets the same error… It’s really hopeless… :sob:
We really want to use the web3auth service in our project. :face_holding_back_tears:

I’m careful, but I think it’s this issue. I’m attaching the contents of the website of Vite.

Module “crypto” has been externalized for browser compatibility. Cannot access “crypto.createHash” in client code. See Troubleshooting | Vite for more details.

When you use a Node.js module in the browser, Vite will output the following warning.

Module "fs" has been externalized for browser compatibility. Cannot access "fs.readFile" in client code.

This is because Vite does not automatically polyfill Node.js modules.

We recommend avoiding Node.js modules for browser code to reduce the bundle size, although you can add polyfills manually. If the module is imported from a third-party library (that's meant to be used in the browser), it's advised to report the issue to the respective library.

Can you try the Bundler Polyfill guide for Vite and check if this solves the issue?

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.