Merkle-tree on Front end side

Hi been confused around merkletreejs

import { StandardMerkleTree } from "@openzeppelin/merkle-tree";
import fs from "fs"; //here's the error
const tree = StandardMerkleTree.load(JSON.parse(fs.readFileSync("tree.json")));

i'm using next.js and typescript for it. since fs doenst work here.
how can i load this perfectly.?
or any alternative way to get it done

can you help me pls

The code above is not valid in javascript; try the code below instead:

const { StandardMerkleTree } = require("@openzeppelin/merkle-tree");
const fs = require("fs");

Failed to compile . is there any wrong setting in my package.json?

You're gonna have to do better than throwing lines of code here.
How exactly is anyone here supposed to know what you have executed???
For example, is it node next.js, have you run npm install or yarn install prior to that, what does your package.json file look like, etc.

alright thank you sir.
since i'm newbie and try to figure it out for 2 days i ask here. but thats fine.
i'll keep my learning
thanks alot appreciate it

1 Like

Indeed fs can't be used on the frontend because there's no file system (fs for short), but the Merkle Tree library can.

Depending on the source of your tree (eg. user input vs stored in a backend), I'd load the tree into the UI by another mechanism that's not the file system. It could be sending the tree via HTTP to your front end or reading from user input.

1 Like

so it should placed on another place.
thank you