Skip to content

enforce the server-only constraint #1

Description

@safwanyp

first of all, really good idea! i plan to use it in a self hosted stack of mine and you dropped it at a great time!

a question though - since the readme says "Domain SDK is server-side only", do you think it'd be worth adding some kind of guardrail to prevent the sdk from being initialized in a client env?

something as simple as a window check maybe:

function assertServerEnvironment(): void {
  const isBrowser = typeof window !== "undefined" || typeof document !== "undefined";

  if (isBrowser) {
    throw new Error("Domain SDK is server-side only");
  }
}

happy to raise a pr if you think it's worth adding in.

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