diff --git a/docs/pages/getting-started.mdx b/docs/pages/getting-started.mdx index a69c341f..2eea8323 100644 --- a/docs/pages/getting-started.mdx +++ b/docs/pages/getting-started.mdx @@ -27,6 +27,7 @@ Now you can create a PolkadotClient with a provider of your choice and start int + + ```ts + // [!include ~/snippets/gettingStarted.ts:import] + import { getSmProvider } from "polkadot-api/sm-provider"; + import { chainSpec } from "polkadot-api/chains/polkadot"; + import { startFromWorker } from "polkadot-api/smoldot/from-node-worker"; + import { fileURLToPath } from "url" + import { Worker } from "worker_threads" + + const workerPath = fileURLToPath( + import.meta.resolve("polkadot-api/smoldot/node-worker") + ); + // Or with cjs + // const workerPath = require.resolve("polkadot-api/smoldot/node-worker"); + const worker = new Worker(workerPath); + const smoldot = startFromWorker(worker); + const chain = await smoldot.addChain({ chainSpec }); + + // Connect to the polkadot relay chain. + const client = createClient( + getSmProvider(chain) + ); + + // [!include ~/snippets/gettingStarted.ts:usage] + ``` ```ts