Skip to content

Error: Module not found: Can't resolve 'fs' in next.js client components #1586

@clar1k

Description

@clar1k

Main Dependencies:
"next": "^15.2.3",
"@drift-labs/sdk": "^2.120.0-beta.1",

Code sandbox where error reproduced

Code Sandbox

Description

I get error "Module not found: Can't resolve 'fs'" if i use DriftClient on client side on client of application in next.js
I get same error in the vite repo also.

Full screenshot of the error i am getting

Image

Code where i create drift client

"use client";
import { Connection, Keypair } from "@solana/web3.js";
import { DriftClient, Wallet } from "@drift-labs/sdk";
import { env } from "@/env";
const connection = new Connection(env.NEXT_PUBLIC_RPC_URL, "confirmed");

const keypair = Keypair.generate();

export const wallet = new Wallet(keypair);

export const driftClient = new DriftClient({
  connection,
  wallet,
  env: "mainnet-beta",
});

await driftClient.subscribe();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions