Ar-js and web environments
LorimerJenkins opened this issue · comments
Lorimer Jenkins commented
When in a next-js TS app, calling Arweave.init there is this error
Unhandled Runtime Error
TypeError: arweave__WEBPACK_IMPORTED_MODULE_5__.init is not a function
Code as follows
import Arweave from "arweave"
const arweave = Arweave.init({
host: 'arweave.net',
port: 443,
protocol: 'https'
});
const JWK_public_key = arweave.wallets.jwkToAddress(jwk)
Ros Mc Mahon commented
Would this code be running on the server, browser, or both - hint, it can't run on both
Lorimer Jenkins commented
Hey @rosmcmahon
This code is just running in the browser
Ros Mc Mahon commented
You will have to give more information. There are many projects using arweave-js successfully with nextjs.
Here is a reference to what I'm guessing may be wrong https://flaviocopes.com/nextjs-server-client-code/
Ros Mc Mahon commented
i'm closing this for now, feel free to reopen, or start a conversation in the Arweave Dev Talk support discord