Skip to content

Commit 8dc7e3a

Browse files
committed
Migrate @solana/react to depend on @solana/kit (peer) and re-export @solana/subscribable from kit
Switches `@solana/react` from pinning each consumed Kit sub-package individually to a single `@solana/kit` peer dependency. Promoting Kit to a peer means apps that depend on both `@solana/react` and `@solana/kit` get one deduplicated Kit instance — important for anything relying on shared types and `instanceof SolanaError` checks — and lets consumers upgrade Kit independently of React within the peer range. Mirrors the convention used by Solana program clients. To support a single import root, this branch also adds `export * from '@solana/subscribable'` to the `@solana/kit` barrel. The reactive store types (`ReactiveStreamSource`, `ReactiveStreamStore`, `ReactiveActionSource`, etc.) and helpers (`createReactiveActionStore`, `createReactiveStoreFromDataPublisherFactory`) were already needed by anyone consuming Kit's `PendingRpcSubscriptionsRequest.reactiveStore()` — promoting them onto the Kit surface formalises that. Every `import { … } from '@solana/subscribable'` (and the remaining sub-package imports) in `packages/react/src/**` is rewritten to `from '@solana/kit'`. No behaviour change beyond the dep-tree shape; `@solana/kit` itself depends on the same sub-packages. `@solana/promises` stays a direct dep — it's a small utility not part of Kit's public surface.
1 parent 973fcc8 commit 8dc7e3a

32 files changed

Lines changed: 108 additions & 112 deletions

.changeset/purple-readers-obey.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
'@solana/react': patch
3+
'@solana/kit': minor
4+
---
5+
6+
Migrate `@solana/react` to depend on `@solana/kit` as a peer dependency (replacing its individual workspace sub-package deps) and re-export `@solana/subscribable` from `@solana/kit` so React consumers have a single import root. `@solana/promises` remains as a direct dep — it's a small utility that isn't part of Kit's public surface.
7+
8+
For `@solana/react` users:
9+
- `@solana/kit` must now be installed alongside `@solana/react`.
10+
- Apps that already use both get a single deduplicated `@solana/kit` instance — important for anything relying on shared types or `instanceof SolanaError` checks.
11+
- Kit can be bumped independently of React within the peer range.
12+
13+
For `@solana/kit` users:
14+
- `ReactiveStreamSource`, `ReactiveStreamStore`, `ReactiveActionSource`, `ReactiveActionStore`, `ReactiveState`, `createReactiveActionStore`, `createReactiveStoreFromDataPublisherFactory`, `DataPublisher` and the rest of `@solana/subscribable`'s surface are now reachable directly through `@solana/kit`.

packages/kit/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export * from '@solana/rpc-parsed-types';
2323
export * from '@solana/rpc-subscriptions';
2424
export * from '@solana/rpc-types';
2525
export * from '@solana/signers';
26+
export * from '@solana/subscribable';
2627
export * from '@solana/transaction-messages';
2728
export * from '@solana/transactions';
2829
export * from './create-async-generator-with-initial-value-and-slot-tracking';

packages/react/package.json

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,15 +74,7 @@
7474
"maintained node versions"
7575
],
7676
"dependencies": {
77-
"@solana/addresses": "workspace:*",
78-
"@solana/errors": "workspace:*",
79-
"@solana/keys": "workspace:*",
80-
"@solana/plugin-core": "workspace:*",
8177
"@solana/promises": "workspace:*",
82-
"@solana/signers": "workspace:*",
83-
"@solana/subscribable": "workspace:*",
84-
"@solana/transaction-messages": "workspace:*",
85-
"@solana/transactions": "workspace:*",
8678
"@solana/wallet-standard-features": "^1.3.0",
8779
"@wallet-standard/base": "^1.1.0",
8880
"@wallet-standard/errors": "^0.1.1",
@@ -91,9 +83,8 @@
9183
"@wallet-standard/ui-registry": "^1.0.1"
9284
},
9385
"devDependencies": {
94-
"@solana/codecs-core": "workspace:*",
9586
"@solana/eslint-config": "workspace:*",
96-
"@solana/rpc-types": "workspace:*",
87+
"@solana/kit": "workspace:*",
9788
"@testing-library/react": "^16.3.2",
9889
"@types/react": "^19.2.16",
9990
"@types/react-dom": "^19.2.3",
@@ -104,6 +95,7 @@
10495
"react-test-renderer": "^19.2.6"
10596
},
10697
"peerDependencies": {
98+
"@solana/kit": "workspace:*",
10799
"react": ">=18"
108100
},
109101
"peerDependenciesMeta": {

packages/react/src/ClientProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { Client } from '@solana/plugin-core';
1+
import type { Client } from '@solana/kit';
22
import React from 'react';
33

44
import { usePromise } from './usePromise';

packages/react/src/__tests__/ClientProvider-test.browser.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
import { isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/errors';
2-
import { Client, createClient } from '@solana/plugin-core';
1+
import { Client, createClient, isSolanaError, SOLANA_ERROR__REACT__MISSING_PROVIDER } from '@solana/kit';
32
import { act } from '@testing-library/react';
43
import React, { Suspense } from 'react';
54
import { ErrorBoundary } from 'react-error-boundary';
65

6+
import { render, renderHook } from '../__test-utils__/render';
77
import { ClientProvider } from '../ClientProvider';
88
import { useClient } from '../useClient';
9-
import { render, renderHook } from '../__test-utils__/render';
109

1110
describe('ClientProvider + useClient', () => {
1211
it('publishes the client to descendants and returns the same reference across renders', () => {
@@ -110,7 +109,7 @@ describe('ClientProvider + useClient', () => {
110109
const clientPromise = Promise.reject<Client<object>>(boom);
111110
// Pre-attach a catch so the rejection isn't flagged as unhandled before React's
112111
// error-boundary subscription runs.
113-
clientPromise.catch(() => {});
112+
clientPromise.catch(() => { });
114113
const onError = jest.fn();
115114
function Probe() {
116115
useClient();

packages/react/src/__tests__/useAction-test.browser.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import React from 'react';
44
import { renderToString } from 'react-dom/server';
55

66
import { renderHook } from '../__test-utils__/render';
7-
87
import { useAction } from '../useAction';
98

109
describe('useAction', () => {

packages/react/src/__tests__/useClientCapability-test.browser.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import {
2+
createClient,
23
isSolanaError,
34
SOLANA_ERROR__REACT__MISSING_CAPABILITY,
45
SOLANA_ERROR__REACT__MISSING_PROVIDER,
5-
} from '@solana/errors';
6-
import { createClient } from '@solana/plugin-core';
6+
} from '@solana/kit';
77
import React from 'react';
88

9+
import { renderHook } from '../__test-utils__/render';
910
import { ClientProvider } from '../ClientProvider';
1011
import { useClient } from '../useClient';
1112
import { useClientCapability } from '../useClientCapability';
12-
import { renderHook } from '../__test-utils__/render';
1313

1414
type ClientWithFoo = { foo: { hello(): string } };
1515

packages/react/src/__tests__/useRequest-test.browser.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createReactiveActionStore, ReactiveActionSource } from '@solana/subscribable';
1+
import { createReactiveActionStore, ReactiveActionSource } from '@solana/kit';
22
import { act } from '@testing-library/react';
33
import React from 'react';
44
import { renderToString } from 'react-dom/server';

packages/react/src/__tests__/useSubscription-test.browser.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1-
import { SolanaRpcResponse } from '@solana/rpc-types';
2-
import { createReactiveStoreFromDataPublisherFactory, DataPublisher, ReactiveStreamSource } from '@solana/subscribable';
1+
import {
2+
createReactiveStoreFromDataPublisherFactory,
3+
DataPublisher,
4+
ReactiveStreamSource,
5+
SolanaRpcResponse,
6+
} from '@solana/kit';
37
import { act } from '@testing-library/react';
48
import React from 'react';
59
import { renderToString } from 'react-dom/server';

packages/react/src/__tests__/useWalletAccountMessageSigner-test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/errors';
2-
import { SignatureBytes } from '@solana/keys';
1+
import { SignatureBytes, SOLANA_ERROR__SIGNER__WALLET_MULTISIGN_UNIMPLEMENTED, SolanaError } from '@solana/kit';
32
import type { UiWalletAccount } from '@wallet-standard/ui';
43

54
import { renderHook } from '../test-renderer';

0 commit comments

Comments
 (0)