Skip to content

Commit

Permalink
docs: add example on how to use WebSocket provider
Browse files Browse the repository at this point in the history
  • Loading branch information
tien committed Jun 28, 2024
1 parent 78cc1a2 commit a744ae4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions apps/docs/docs/getting-started/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ declare module "@reactive-dot/core" {

## Create config

{/* prettier-ignore-start */}

<Tabs>
<TabItem value="light-client" label="Light client" default>

{/* prettier-ignore-end */}

```ts title="config.ts"
import { dot } from "@polkadot-api/descriptors";
import type { Config } from "@reactive-dot/core";
Expand Down Expand Up @@ -95,6 +102,39 @@ const config: Config = {
export default config;
```

{/* prettier-ignore-start */}

</TabItem>
<TabItem value="ws" label="WebSocket">

{/* prettier-ignore-end */}

```ts title="config.ts"
import { dot } from "@polkadot-api/descriptors";
import { WebSocketProvider } from "@polkadot-api/ws-provider/web";
import type { Config } from "@reactive-dot/core";
import { InjectedWalletAggregator } from "@reactive-dot/core/wallets.js";

const config: Config = {
chains: {
polkadot: {
descriptor: dot,
provider: WebSocketProvider("wss://polkadot-rpc.publicnode.com"),
},
},
wallets: [new InjectedWalletAggregator()],
};

export default config;
```

{/* prettier-ignore-start */}

</TabItem>
</Tabs>

{/* prettier-ignore-end */}

## Wrap app in context providers

```tsx title="App.tsx"
Expand Down

0 comments on commit a744ae4

Please sign in to comment.