javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Make Web3 wallet adapter dependencies optional for headless-only consumers (e.g., React Native via clerk-expo)

Open Arnos0 opened this issue 6 months ago • 8 comments

Context

@clerk/clerk-expo consumers on React Native use clerk-js/headless which has no Web3 sign-in code path. However, the Web3 wallet adapter packages are declared as regular dependencies of upstream Clerk packages, so they are installed into node_modules regardless of whether the consumer app uses Web3 features.

In our project (a motorcycle navigation app — no crypto features whatsoever) this results in:

  • ~7 MB of node_modules for code that is never bundled or executed (Metro tree-shakes correctly so the JS bundle is clean)
  • npm audit noise from vulnerabilities reported in @solana/*, @coinbase/*, etc. that don't apply to our runtime
  • Slower CI installs and increased supply-chain audit surface

Affected packages observed in our tree

  • @solana/wallet-adapter-base
  • @solana/wallet-adapter-react
  • @solana/wallet-standard
  • @solana-mobile/wallet-adapter-mobile
  • @solana/wallet-standard-wallet-adapter (base + react variants)
  • @wallet-standard/core
  • @coinbase/wallet-sdk
  • @base-org/account

Request

Either:

  1. Move these packages to peerDependenciesMeta.optional so consumers can opt out, OR
  2. Publish a separate @clerk/clerk-js-headless package with only the deps needed for headless flows (no Web3, no UI components)

Option 2 is more ergonomic for React Native consumers via @clerk/clerk-expo since they're inherently headless.

Workaround we considered but rejected

npm overrides with stub packages — works but brittle across Clerk upgrades, and gets flagged by some supply-chain audit tools.

Happy to provide more context on our setup if useful.

Arnos0 avatar May 08 '26 06:05 Arnos0

Hello 👋

We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! 🙏

github-actions[bot] avatar Jun 08 '26 00:06 github-actions[bot]

I noticed a similar issue with the new recommendation to install @clerk/ui as a solution to a potential issue where some styles could break on update:

Clerk: Structural CSS detected that may break on updates.

Found:
  - CSS ".css-4rhs7b .cl-card"
  - CSS ".css-4rhs7b .cl-button"
  - CSS ".css-4rhs7b .cl-button:focus"
  - CSS ".css-4rhs7b .cl-button[data-focus]"
  - CSS ".css-4rhs7b .cl-formFieldInput[type="text"]"
  (+118 more)

These selectors depend on the internal DOM structure of Clerk's components, which may change when Clerk deploys component updates.
To prevent breaking changes, install @clerk/ui and pass it to ClerkProvider:

  import { ui } from '@clerk/ui'
  <ClerkProvider ui={ui}>

Learn more: https://clerk.com/docs/reference/components/versioning
(code=structural_css_pin_clerk_ui)

I attempted installing @clerk/ui and passing it to the Clerk provider, but it seems like it's increasing our Next.js bundle size massively, even though we're not using any of the Web3 based auth features.

I'm not sure if this is inaccurate due to the UI modules just being loaded asynchronously previously, but it still seems like overkill to have all of these packages installed.

In general, I am a fan of the peer dependencies route with peerDependenciesMeta.optional for these additional packages, otherwise they're heavily exploding the dependency tree with unused transitive dependencies that could leave users more open to supply chain attacks.

csandman avatar Jun 09 '26 18:06 csandman

Hello 👋

We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! 🙏

github-actions[bot] avatar Jul 11 '26 00:07 github-actions[bot]

This hasn't been addressed yet

csandman avatar Jul 14 '26 20:07 csandman

Please address this

19Ash82 avatar Jul 24 '26 14:07 19Ash82

+1 Please address this.

wevial avatar Jul 29 '26 17:07 wevial

Hello 👋

We currently close issues after 40 days of inactivity. It's been 30 days since the last update here. If we missed this issue, please reply here. Otherwise, we'll close this issue in 10 days.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! 🙏

github-actions[bot] avatar Aug 29 '26 00:08 github-actions[bot]

Hello again 👋

After 40 days of no activity, we'll close this issue. Keep in mind, I'm just a robot, so if I've closed this issue in error, please reply here and my human colleagues will reopen it.

As a friendly reminder: The best way to see an issue fixed is to open a pull request. If you're not sure how to do that, please check out our contributing guide.

Thanks for being a part of the Clerk community! 🙏

github-actions[bot] avatar Sep 08 '26 00:09 github-actions[bot]