Docs
Upgrading from V1

Upgrading from V1

This guide will help you upgrade from Starknet React V1.

Updating dependencies

First, update all dependencies and double check that the installed version of @starknet-react/core is at least 2.0.0.

npm
pnpm
yarn
1
npm install @starknet-react/chains@next @starknet-react/core@next starknet get-starknet-core

Update StarknetConfig

Update the existing StarknetConfig by adding the new chains and providers options. You also need to update the connectors passed to it.

  • chains: a list of chains supported by your dapp. The first chain in the list is the default chain, used when the user doesn't connect their wallet.
  • providers: an RPC provider. See the providers section for more information.
  • connectors: in v2, basic information about a wallet (like the id and name) must be provided. Starknet React provides helpers to initialize connectors for the most popular wallets.
components/starknet-provider.tsx
1
import { goerli } from "@starknet-react/chains";
2
import {
3
StarknetConfig,
4
publicProvider,
5
argent,
6
braavos,
7
} from "@starknet-react/core";
8

9
export function StarknetProvider({ children }: { children: React.ReactNode }) {
10
const chains = [goerli];
11
const providers = [publicProvider()];
12
const connectors = [argent(), braavos()];
13

14
return (
15
<StarknetConfig
16
chains={chains}
17
providers={providers}
18
connectors={connectors}
19
>
20
{children}
21
</StarknetConfig>
22
);
23
}

Transaction manager

The transaction manager is now gone 💀 Fear not, it's easy to replace it using standard React tools 😇

This decision was not easy, but we noticed that the hook and context were cause of some issues and many teams decided to implement their own solution using their favourite state management library.

The easiest way to upgrade is by following the code in the transaction manager demo. Once you finish upgrading, you will have a transaction manager that's easier to customize and that persists the transaction list between page reloads.