Skip to content

Migrate @solana/react to import from @solana/kit#1706

Open
mcintyre94 wants to merge 1 commit into
react/use-subscriptionfrom
react/depend-on-kit
Open

Migrate @solana/react to import from @solana/kit#1706
mcintyre94 wants to merge 1 commit into
react/use-subscriptionfrom
react/depend-on-kit

Conversation

@mcintyre94
Copy link
Copy Markdown
Member

@mcintyre94 mcintyre94 commented May 27, 2026

Summary of Changes

This PR changes the imports of @solana/react to use @solana/kit instead of the individual sub-packages (addresses, transactions, etc) wherever possible

This explicitly makes @solana/kit a dependency of @solana/react. This is ok because we will never want to export @solana/react from @solana/kit because of its react dependency.

We do this because a following PR will use createReactiveStoreWithInitialValueAndSlotTracking from @solana/kit. This is a separate PR to make reviewing easier and keep that one focused.

Copy link
Copy Markdown
Member Author

mcintyre94 commented May 27, 2026

@bundlemon
Copy link
Copy Markdown

bundlemon Bot commented May 27, 2026

BundleMon

Files updated (25)
Status Path Size Limits
react/dist/index.browser.mjs
4.49KB (+1.39KB +45.06%) -
react/dist/index.native.mjs
4.49KB (+1.39KB +45.08%) -
react/dist/index.node.mjs
4.49KB (+1.39KB +45.06%) -
subscribable/dist/index.node.mjs
2.82KB (+144B +5.25%) -
subscribable/dist/index.browser.mjs
2.74KB (+142B +5.32%) -
subscribable/dist/index.native.mjs
2.75KB (+142B +5.31%) -
rpc-types/dist/index.browser.mjs
1.92KB (+126B +6.83%) -
rpc-types/dist/index.native.mjs
1.92KB (+126B +6.84%) -
rpc-types/dist/index.node.mjs
1.92KB (+125B +6.79%) -
wallet-account-signer/dist/index.browser.mjs
17.57KB (+45B +0.25%) -
wallet-account-signer/dist/index.native.mjs
17.57KB (+45B +0.25%) -
wallet-account-signer/dist/index.node.mjs
17.59KB (+44B +0.24%) -
errors/dist/index.browser.mjs
20.76KB (+36B +0.17%) -
errors/dist/index.native.mjs
20.76KB (+35B +0.16%) -
errors/dist/index.node.mjs
20.78KB (+35B +0.16%) -
rpc-subscriptions-spec/dist/index.browser.mjs
2.19KB (-13B -0.58%) -
rpc-subscriptions-spec/dist/index.native.mjs
2.19KB (-13B -0.58%) -
rpc-subscriptions-spec/dist/index.node.mjs
2.23KB (-13B -0.56%) -
rpc-spec/dist/index.browser.mjs
898B (-20B -2.18%) -
rpc-spec/dist/index.native.mjs
897B (-21B -2.29%) -
rpc-spec/dist/index.node.mjs
896B (-21B -2.29%) -
@solana/kit production bundle
kit/dist/index.production.min.js
52.49KB (-129B -0.24%) -
kit/dist/index.node.mjs
4.13KB (-352B -7.69%) -
kit/dist/index.browser.mjs
4.13KB (-353B -7.71%) -
kit/dist/index.native.mjs
4.13KB (-353B -7.71%) -
Unchanged files (122)
Status Path Size Limits
rpc-graphql/dist/index.browser.mjs
18.82KB -
rpc-graphql/dist/index.native.mjs
18.81KB -
rpc-graphql/dist/index.node.mjs
18.81KB -
transaction-messages/dist/index.browser.mjs
11.32KB -
transaction-messages/dist/index.native.mjs
11.32KB -
transaction-messages/dist/index.node.mjs
11.32KB -
instruction-plans/dist/index.browser.mjs
6.58KB -
instruction-plans/dist/index.native.mjs
6.58KB -
instruction-plans/dist/index.node.mjs
6.58KB -
fixed-points/dist/index.browser.mjs
5.08KB -
fixed-points/dist/index.native.mjs
5.07KB -
fixed-points/dist/index.node.mjs
5.07KB -
codecs-data-structures/dist/index.browser.mjs
5.04KB -
codecs-data-structures/dist/index.native.mjs
5.03KB -
codecs-data-structures/dist/index.node.mjs
5.03KB -
offchain-messages/dist/index.browser.mjs
4.89KB -
offchain-messages/dist/index.native.mjs
4.89KB -
offchain-messages/dist/index.node.mjs
4.89KB -
transactions/dist/index.browser.mjs
4.07KB -
transactions/dist/index.native.mjs
4.07KB -
transactions/dist/index.node.mjs
4.07KB -
codecs-core/dist/index.browser.mjs
3.62KB -
codecs-core/dist/index.native.mjs
3.62KB -
codecs-core/dist/index.node.mjs
3.62KB -
webcrypto-ed25519-polyfill/dist/index.node.mj
s
3.61KB -
webcrypto-ed25519-polyfill/dist/index.browser
.mjs
3.59KB -
webcrypto-ed25519-polyfill/dist/index.native.
mjs
3.57KB -
rpc-subscriptions/dist/index.browser.mjs
3.37KB -
rpc-subscriptions/dist/index.node.mjs
3.34KB -
rpc-subscriptions/dist/index.native.mjs
3.31KB -
signers/dist/index.browser.mjs
3.26KB -
signers/dist/index.native.mjs
3.26KB -
signers/dist/index.node.mjs
3.26KB -
rpc-transformers/dist/index.browser.mjs
3.16KB -
rpc-transformers/dist/index.native.mjs
3.16KB -
rpc-transformers/dist/index.node.mjs
3.16KB -
keys/dist/index.node.mjs
3.06KB -
addresses/dist/index.browser.mjs
2.93KB -
addresses/dist/index.native.mjs
2.92KB -
addresses/dist/index.node.mjs
2.92KB -
keys/dist/index.browser.mjs
2.85KB -
keys/dist/index.native.mjs
2.85KB -
codecs-strings/dist/index.browser.mjs
2.55KB -
codecs-strings/dist/index.node.mjs
2.51KB -
codecs-strings/dist/index.native.mjs
2.47KB -
transaction-confirmation/dist/index.node.mjs
2.42KB -
transaction-confirmation/dist/index.native.mj
s
2.37KB -
sysvars/dist/index.browser.mjs
2.37KB -
sysvars/dist/index.native.mjs
2.37KB -
transaction-confirmation/dist/index.browser.m
js
2.37KB -
sysvars/dist/index.node.mjs
2.37KB -
rpc/dist/index.node.mjs
1.95KB -
codecs-numbers/dist/index.browser.mjs
1.95KB -
codecs-numbers/dist/index.native.mjs
1.95KB -
codecs-numbers/dist/index.node.mjs
1.94KB -
rpc-transport-http/dist/index.browser.mjs
1.91KB -
rpc-transport-http/dist/index.native.mjs
1.9KB -
rpc/dist/index.native.mjs
1.81KB -
rpc/dist/index.browser.mjs
1.8KB -
rpc-transport-http/dist/index.node.mjs
1.72KB -
rpc-subscriptions-channel-websocket/dist/inde
x.node.mjs
1.33KB -
rpc-subscriptions-channel-websocket/dist/inde
x.native.mjs
1.27KB -
rpc-subscriptions-channel-websocket/dist/inde
x.browser.mjs
1.26KB -
program-client-core/dist/index.browser.mjs
1.21KB -
program-client-core/dist/index.native.mjs
1.21KB -
program-client-core/dist/index.node.mjs
1.21KB -
options/dist/index.browser.mjs
1.18KB -
options/dist/index.native.mjs
1.18KB -
options/dist/index.node.mjs
1.17KB -
accounts/dist/index.browser.mjs
1.17KB -
accounts/dist/index.native.mjs
1.17KB -
accounts/dist/index.node.mjs
1.16KB -
rpc-api/dist/index.browser.mjs
998B -
rpc-api/dist/index.native.mjs
997B -
rpc-api/dist/index.node.mjs
995B -
compat/dist/index.browser.mjs
969B -
compat/dist/index.native.mjs
968B -
compat/dist/index.node.mjs
966B -
rpc-spec-types/dist/index.browser.mjs
962B -
rpc-spec-types/dist/index.native.mjs
961B -
rpc-spec-types/dist/index.node.mjs
959B -
rpc-subscriptions-api/dist/index.native.mjs
871B -
rpc-subscriptions-api/dist/index.browser.mjs
870B -
rpc-subscriptions-api/dist/index.node.mjs
870B -
promises/dist/index.native.mjs
841B -
promises/dist/index.node.mjs
840B -
promises/dist/index.browser.mjs
839B -
plugin-core/dist/index.browser.mjs
820B -
plugin-core/dist/index.native.mjs
819B -
plugin-core/dist/index.node.mjs
817B -
assertions/dist/index.browser.mjs
783B -
instructions/dist/index.browser.mjs
771B -
instructions/dist/index.native.mjs
770B -
instructions/dist/index.node.mjs
768B -
fast-stable-stringify/dist/index.browser.mjs
726B -
fast-stable-stringify/dist/index.native.mjs
725B -
assertions/dist/index.native.mjs
724B -
fast-stable-stringify/dist/index.node.mjs
724B -
assertions/dist/index.node.mjs
723B -
programs/dist/index.browser.mjs
329B -
programs/dist/index.native.mjs
327B -
programs/dist/index.node.mjs
325B -
fs-impl/dist/index.browser.mjs
245B -
event-target-impl/dist/index.node.mjs
230B -
functional/dist/index.browser.mjs
154B -
functional/dist/index.native.mjs
152B -
text-encoding-impl/dist/index.native.mjs
152B -
functional/dist/index.node.mjs
151B -
codecs/dist/index.browser.mjs
145B -
codecs/dist/index.native.mjs
144B -
codecs/dist/index.node.mjs
142B -
event-target-impl/dist/index.browser.mjs
133B -
ws-impl/dist/index.node.mjs
131B -
text-encoding-impl/dist/index.browser.mjs
122B -
fs-impl/dist/index.node.mjs
120B -
text-encoding-impl/dist/index.node.mjs
119B -
ws-impl/dist/index.browser.mjs
113B -
crypto-impl/dist/index.node.mjs
111B -
crypto-impl/dist/index.browser.mjs
109B -
rpc-parsed-types/dist/index.browser.mjs
66B -
rpc-parsed-types/dist/index.native.mjs
65B -
rpc-parsed-types/dist/index.node.mjs
63B -

Total files change +3.95KB +0.75%

Final result: ✅

View report in BundleMon website ➡️


Current branch size history | Target branch size history

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 27, 2026

Documentation Preview: https://kit-docs-c2wzlsuff-anza-tech.vercel.app

@mcintyre94 mcintyre94 changed the base branch from react/use-subscription to graphite-base/1706 May 27, 2026 12:00
@mcintyre94 mcintyre94 force-pushed the graphite-base/1706 branch from 72a4b00 to af665ca Compare May 27, 2026 12:14
@mcintyre94 mcintyre94 force-pushed the react/depend-on-kit branch from 6f4954b to f0123e1 Compare May 27, 2026 12:14
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: 543f1d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 47 packages
Name Type
@solana/react Patch
@solana/accounts Patch
@solana/addresses Patch
@solana/assertions Patch
@solana/codecs-core Patch
@solana/codecs-data-structures Patch
@solana/codecs-numbers Patch
@solana/codecs-strings Patch
@solana/codecs Patch
@solana/compat Patch
@solana/errors Patch
@solana/fast-stable-stringify Patch
@solana/fixed-points Patch
@solana/functional Patch
@solana/instruction-plans Patch
@solana/instructions Patch
@solana/keys Patch
@solana/kit Patch
@solana/nominal-types Patch
@solana/offchain-messages Patch
@solana/options Patch
@solana/plugin-core Patch
@solana/plugin-interfaces Patch
@solana/program-client-core Patch
@solana/programs Patch
@solana/promises Patch
@solana/rpc-api Patch
@solana/rpc-graphql Patch
@solana/rpc-parsed-types Patch
@solana/rpc-spec-types Patch
@solana/rpc-spec Patch
@solana/rpc-subscriptions-api Patch
@solana/rpc-subscriptions-channel-websocket Patch
@solana/rpc-subscriptions-spec Patch
@solana/rpc-subscriptions Patch
@solana/rpc-transformers Patch
@solana/rpc-transport-http Patch
@solana/rpc-types Patch
@solana/rpc Patch
@solana/signers Patch
@solana/subscribable Patch
@solana/sysvars Patch
@solana/transaction-confirmation Patch
@solana/transaction-messages Patch
@solana/transactions Patch
@solana/wallet-account-signer Patch
@solana/webcrypto-ed25519-polyfill Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mcintyre94 mcintyre94 changed the base branch from graphite-base/1706 to react/use-subscription May 27, 2026 12:14
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 27, 2026

🦋 Changeset detected

Latest commit: f0123e1

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 47 packages
Name Type
@solana/react Patch
@solana/accounts Patch
@solana/addresses Patch
@solana/assertions Patch
@solana/codecs-core Patch
@solana/codecs-data-structures Patch
@solana/codecs-numbers Patch
@solana/codecs-strings Patch
@solana/codecs Patch
@solana/compat Patch
@solana/errors Patch
@solana/fast-stable-stringify Patch
@solana/fixed-points Patch
@solana/functional Patch
@solana/instruction-plans Patch
@solana/instructions Patch
@solana/keys Patch
@solana/kit Patch
@solana/nominal-types Patch
@solana/offchain-messages Patch
@solana/options Patch
@solana/plugin-core Patch
@solana/plugin-interfaces Patch
@solana/program-client-core Patch
@solana/programs Patch
@solana/promises Patch
@solana/rpc-api Patch
@solana/rpc-graphql Patch
@solana/rpc-parsed-types Patch
@solana/rpc-spec-types Patch
@solana/rpc-spec Patch
@solana/rpc-subscriptions-api Patch
@solana/rpc-subscriptions-channel-websocket Patch
@solana/rpc-subscriptions-spec Patch
@solana/rpc-subscriptions Patch
@solana/rpc-transformers Patch
@solana/rpc-transport-http Patch
@solana/rpc-types Patch
@solana/rpc Patch
@solana/signers Patch
@solana/subscribable Patch
@solana/sysvars Patch
@solana/transaction-confirmation Patch
@solana/transaction-messages Patch
@solana/transactions Patch
@solana/wallet-account-signer Patch
@solana/webcrypto-ed25519-polyfill Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mcintyre94
Copy link
Copy Markdown
Member Author

@trevor-cortex

@mcintyre94 mcintyre94 force-pushed the react/depend-on-kit branch from f0123e1 to 31b62af Compare May 27, 2026 12:23
Copy link
Copy Markdown

@trevor-cortex trevor-cortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mechanical migration of @solana/react's source/test/typetest imports from the individual @solana/* sub-packages onto the @solana/kit umbrella, plus the corresponding package.json dependency swap. All re-exports check out — every symbol pulled in (Address, address, bytesEqual, SignatureBytes, Client, MessageModifyingSigner, TransactionModifyingSigner, TransactionSendingSigner, getCompiledTransactionMessageDecoder, getTransactionCodec, getTransactionEncoder, assertIsTransactionWithinSizeLimit, getTransactionLifetimeConstraintFromCompiledTransactionMessage, Transaction, TransactionWithinSizeLimit, TransactionWithLifetime, Slot, Blockhash, SolanaRpcResponse, UnwrapRpcResponse, splitSolanaRpcResponse, SOLANA_ERROR__*, SolanaError, isSolanaError, createClient, VariableSizeEncoder/Codec/Decoder) is reachable via kit/src/index.ts's export * chain (with bytesEqual and the variable-size codec types flowing through @solana/codecs). The changeset's justification for keeping @solana/promises and @solana/subscribable as direct deps is correct — neither is re-exported by Kit.

The test-mock change from jest.mock('@solana/transactions') / jest.mock('@solana/transaction-messages') to factory-style jest.mock('@solana/kit', () => ({ ...jest.requireActual('@solana/kit'), ... })) is the right call — auto-mocking the whole Kit barrel would replace SolanaError, the SOLANA_ERROR__* constants, bytesEqual, Address, etc., breaking the very assertions these tests rely on. The set of stubbed functions in each file matches the runtime-callable Kit imports of the corresponding SUT.

Main thing worth a follow-up: several touched source/test files end up with multiple import { ... } from '@solana/kit' statements stacked next to each other (the migration was done line-by-line). eslint-plugin-simple-import-sort doesn't merge duplicate sources, but useClientCapability.ts shows the intended end-state with everything (incl. the type Client) collapsed into one statement. See inline comments for the worst offenders.

Minor nit out of scope: the README example for useWalletAccountMessageSigner still imports createSignableMessage from @solana/signers while the matching JSDoc example was updated to @solana/kit in this PR. Worth a follow-up sweep of the README examples (@solana/signers, @solana/codecs-strings, @solana/promises) for consistency with the new orientation, but not blocking here.

Notes for subsequent reviewers:

  • The one-line change in useAction-test.browser.tsx (removing a blank line) is unrelated to the migration. Harmless.
  • This PR sets up the next one which will consume createReactiveStoreWithInitialValueAndSlotTracking from @solana/kit — that symbol is defined in packages/kit/src/create-reactive-store-with-initial-value-and-slot-tracking.ts and exported from the barrel, so the path is ready.

Copy link
Copy Markdown

@trevor-cortex trevor-cortex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inline notes on the duplicate-import pattern — same point applies to a few other touched files (useClient.ts, the two wallet-signer tests).

Comment thread packages/react/src/useWalletAccountMessageSigner.ts Outdated
Comment thread packages/react/src/useWalletAccountTransactionSigner.ts Outdated
Comment thread packages/react/src/__tests__/useWalletAccountTransactionSigner-test.ts Outdated
@mcintyre94 mcintyre94 force-pushed the react/depend-on-kit branch from 31b62af to 80771de Compare May 27, 2026 12:51
Switch the `@solana/react` package to take a single `@solana/kit` workspace dep instead of pinning each consumed sub-package individually. The kit barrel already re-exports `@solana/addresses`, `@solana/errors`, `@solana/keys`, `@solana/plugin-core`, `@solana/signers`, `@solana/transaction-messages`, `@solana/transactions`, `@solana/rpc-types`, and (transitively via `@solana/codecs`) `@solana/codecs-core` — so the granular deps are redundant. `@solana/subscribable` and `@solana/promises` stay as direct deps because they aren't re-exported by Kit.

The migration is mechanical — every `import { … } from '@solana/<sub-package>'` in `src/` becomes `import { … } from '@solana/kit'`. No behavior change; consumers' transitive dep tree is unchanged because `@solana/kit` itself depends on the same sub-packages.

Two wallet-signer tests switched from full-module auto-mocks (`jest.mock('@solana/transactions')` / `jest.mock('@solana/transaction-messages')`) to factory-style mocks (`jest.mock('@solana/kit', () => ({ ...jest.requireActual('@solana/kit'), getTransactionCodec: jest.fn(), … }))`). The bundled `@solana/kit` output doesn't propagate jest's auto-mock through its `export *` re-exports, so listing the specific functions to stub keeps everything else (notably `SolanaError`, error constants, and `bytesEqual`) as the real implementation.

Positions `@solana/react` symmetrically with how a third-party `@solana/vue` / `@solana/svelte` / etc. binding would depend on Kit: one umbrella dep, one place to import from.
"@solana/errors": "workspace:*",
"@solana/keys": "workspace:*",
"@solana/plugin-core": "workspace:*",
"@solana/kit": "workspace:*",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to make it a peer dependency instead if it's a purely additive package? Similar to what we do with the program clients.

Comment on lines +5 to +6
} from '@solana/kit';
import { createClient } from '@solana/kit';
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Let's combine these in a single import statement (I think that's the only instance of that behaviour in the PR).

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants