Running the library client side without node server rendering
bh90210 opened this issue · comments
Helloo, another day another problem.
I am using the library with nextjs with static site generator and I get this error
Unhandled Runtime Error
TypeError: crypto__WEBPACK_IMPORTED_MODULE_2___default().generateKeyPairSync is not a function
Source
pages/transfer/[[...token]].tsx (94:34) @ createOffer
92 | });
93 |
> 94 | pc.setLocalDescription(await pc.createOffer());
| ^
95 | const sdp = JSON.stringify(pc.localDescription);
96 |
97 | const offerInfo = new OfferInfo();
and if I hunt down the problem it leads me to ->
-> -> ->where you make use of
import nodeCrypto, { createSign } from "crypto";
node's crypto package.Of course the crypto is used elsewhere so my question is more general.
Is there a way to not use node but instead make use of https://developer.mozilla.org/en-US/docs/Web/API/Web_Crypto_API? I am trying to use the library on the browser (client side) with no server side rendering at all.
I got this from https://stackoverflow.com/questions/62084998/typeerror-crypto-webpack-imported-module-5-generatekeypairsync-is-not-a-func
This library is not for browsers. Use browser RTCPeerConnection.
werift is a WebRTC Implementation for TypeScript (Node.js), includes ICE/DTLS/SCTP/RTP.