Skip to content

window is not defined error when creating supabase client in nodejs server side #786

@Vichet97

Description

@Vichet97

Bug report

  • [x ] I confirm this is a bug with Supabase, not with my own application.
  • I confirm I have searched the Docs, GitHub Discussions, and Discord.

Describe the bug

I try to create client in nodejs but always get window is not defined error as attached below. Then when i try to debug the source code through stack trace, it turned on that isBrowser() return a True value. But when i manually set it to false, it will work.

To Reproduce

Steps to reproduce the behavior, please provide code snippets or a repository:

  1. create a fastify​ project
  2. import and createClient(host, key, {db: {schema: abc}​}
  3. run the server with node index.js
  4. Got error as attached

Screenshots

This is the error
IMG_20230606_170256_892

Then i debug and got True value when printing isBrowser() which it should be False. I manually change code here then it works.

IMG_20230606_170300_006

System information

  • OS: macOS monetary
  • Version of supabase-js: 2.24.0, I also tried with some older version in Supabase 2. It's the same.
  • Version of Node.js: 14

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions