Web3JS – Client-Side Only Usage of Web3

javascriptweb3js

I have low cost hosting and I cannot install node etc. I have basically just rights to use html and run javascript. Can we use web3 on that basis or do I need a server side installation of node or something like that?

I tried using –

const Web3 = require('web3');

and I get not defined because I have no node installed I think.

Best Answer

web3 can be used either on client side or in NodeJS. You are getting undefined because if you use that kind of syntax in your client application you need to use something like webpack to build your bundle for the browser.

Anyway, another option can be to include web3 inside your front-end downloading it from here. So you can just include it in your HTML

<script type="text/javascript" src="path/to/web3.min.js"></script>
Related Topic