Skip to content

No SSR / Next.js App Router smoke test despite the documented use client guarantee #41

Description

@sidgaikwad

The README makes an explicit SSR promise:

The component works out of the box in React Server Components environments (e.g. Next.js App Router) — it ships with the 'use client' directive and touches the DOM only inside effects.

That claim is backed by a tsup banner:

https://github.com/unlayer/react-image-editor/blob/628b507/tsup.config.ts#L11-L14

…but nothing verifies it. The whole suite runs in jsdom (vitest.config.ts), so every test renders client-side. There is no test that:

  1. the built dist/index.js and dist/index.mjs actually start with 'use client' — a banner is a build-config detail that a bundler or config change could silently drop, and it wouldn't fail any current check;
  2. the component renders without throwing under react-dom/server's renderToString — i.e. that the render path really does stay off the DOM until effects run.

Both are cheap:

// dist smoke test
expect(readFileSync('dist/index.mjs', 'utf8').startsWith("'use client';")).toBe(true);

// SSR smoke test (node environment)
expect(() => renderToString(<ImageEditor image="x" />)).not.toThrow();

The second needs a // @vitest-environment node file (or a second Vitest project) since the current global environment is jsdom. The first needs to run after npm run build, so it fits as a post-build step in the CI checks job.

Given that Next.js App Router is called out by name as a supported target, it's worth having the regression net.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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