Packages

@clerk/shared

4.45.1 · 14 Nov 2026MIT11.8M / weekRepositorynpmAtom feed

Your version

1.0.0

major24 Oct 2023Where it was published

1.4.2 is the newest release of 1.x.

In short

1 breaking3 fixed

  • Breaking

    The package was reworked to allow for better isomorphic use cases and ESM support, resulting in some breaking changes. It now allows for subpath exports and restricts some imports to specific subpaths.

Release note

Major Changes

  • Breaking

    The package was reworked to allow for better isomorphic use cases and ESM support, resulting in some breaking changes. It now allows for subpath exports and restricts some imports to specific subpaths.

    Instead of importing from the root @clerk/shared import you can now use subpaths for most things:

    - import { deprecated, OrganizationProvider } from "@clerk/shared"
    + import { deprecated } from "@clerk/shared/deprecated"
    + import { OrganizationProvider } from "@clerk/shared/react"

    By using subpaths you can tell bundlers to only bundle specific parts, potentially helping with tree-shaking. It also mitigates issues where e.g. modules only relevant for React where picked up in Node.js-only environments.

    If you're not using @clerk/shared directly (only by proxy through e.g. @clerk/clerk-react) you don't need to do anything. If you are relying on @clerk/shared, please read through the breaking changes below and change your code accordingly. You can rely on your IDE to give you hints on which exports are available at @clerk/shared and @clerk/shared/<name> subpaths.

    Breaking Changes

    • @clerk/shared was and still is a dual CJS/ESM package. The ESM files provided by @clerk/shared now use .mjs file extensions and also define them in their import paths, following the ESM spec. Your bundler should handle this for you.

    • Some imports where moved from the root @clerk/shared import to isolated subpaths.

      • Helper utils for cookies and globs:

        - import { createCookieHandler, globs } from "@clerk/shared"
        + import { createCookieHandler } from "@clerk/shared/cookie"
        + import { globs } from "@clerk/shared/globs"
      • Everything related to React. Below is a small example and the full list of exports:

        - import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared"
        + import { useSafeLayoutEffect, ClerkInstanceContext } from "@clerk/shared/react"

        Full list of exports moved to @clerk/shared/react:

        export {
          ClerkInstanceContext,
          ClientContext,
          OrganizationContext,
          OrganizationProvider,
          SessionContext,
          UserContext,
          assertContextExists,
          createContextAndHook,
          useClerkInstanceContext,
          useClientContext,
          useOrganization,
          useOrganizationContext,
          useOrganizationList,
          useOrganizations,
          useSafeLayoutEffect,
          useSessionContext,
          useUserContext,
        };

    If you run into an issues that might be a bug, please open a bug report with a minimal reproduction.

Patch Changes

  • Publish packages with npm provenance enabled

  • Improve internal test coverage and fix small bug inside callWithRetry

  • Update imports of @clerk/shared to granular entrypoints. This addresses warnings during a Next.js build that are the result of unsupported APIs being included in the module graph of builds for the edge runtime.

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.