Web3 APIs & Dev Tools: Starknet React

Tutorials/Guides
Kagemni Karimu
Nov 21, 2023

Intro

Lava spotlights the best web3 APIs & dev tools. Our previous article in this series covered Squid SDK - something you may want to take a look at. Today, we're exploring the Starknet React library by Apibara - the most popular React library on Starknet.

Join us as we uncover the most cutting edge technologies for dapp devs in web3!

Application: Starknet React by Apibara

Inspired by both wagmi and starknet.js, Starknet React is a collection of React hooks useful for building the frontend for Starknet dApps. Now reaching version 2.0 and combined with Apibara’s powerful indexer functionality, it can be used in a complete full-stack setup. Starknet React is an accomplished tool for development - boasting successful projects such as Loot Survivor a fully on-chain NFT game!

Starknet React was created by the Apibara team as an amazing dev tool that takes advantage of Reacts simple component framework:


// $ npm install @starknet-react/chains @starknet-react/core starknet get-starknet-core
"use client";
import React from "react";

import { goerli, mainnet } from "@starknet-react/chains";
import {
  StarknetConfig,
  publicProvider,
  argent,
  braavos,
  useInjectedConnectors,
} from "@starknet-react/core";

export function StarknetProvider({ children }: { children: React.ReactNode }) {
  const { connectors } = useInjectedConnectors({
    // Show these connectors if the user has no connector installed.
    recommended: [
      argent(),
      braavos(),
    ],
    // Hide recommended connectors if the user has any connector installed.
    includeRecommended: "onlyIfNoConnectors",
    // Randomize the order of the connectors.
    order: "random"
  });

  return (
    
      {children}
    
  );
}

Main Features:

  • Collection of React Hooks: Starknet React is built around a collection of React hooks, making it intuitive for developers familiar with React to integrate Starknet functionality into their dApps.
  • Real-Time Transaction and Block Data: Starknet React includes hooks like useWaitForTransaction and useBlock, which allow developers to fetch real-time data about transactions and blocks.
  • Comprehensive Wallet Management: Starknet React includes hooks for connecting, disconnecting, and managing user wallets, such as useConnect, useDisconnect, and useAccount, making wallet interactions seamless and user-friendly.
  • Support for Multicall Transactions: By enabling the bundling of multiple contract calls into a single transaction, it can improve efficiency and user experience, especially in complex dApps.
  • Developer-Friendly Setup and Configuration: The framework provides straightforward setup instructions and configurable components, making it easy for developers to get started and tailor the framework to their specific needs. RPC Providers can even be configured!

Considerations

🟢  Starknet React stands out as a highly versatile and developer-friendly framework for building decentralized applications on the Starknet platform.

Its comprehensive collection of React hooks simplifies the integration of blockchain functionalities into React applications, making it an ideal choice for developers who are already familiar with React. The framework's support for multicall transactions, real-time transaction and block data, and comprehensive wallet management functionalities are particularly noteworthy.

🔴 Starknet React, being a specialized tool for integrating Starknet with React, may present a learning curve for developers not familiar with React or those accustomed to different blockchain frameworks.

Moreover, as with any technology relying on blockchain and smart contracts, and using javascript, developers need to be mindful of the security implications and best practices for smart contract development to ensure the safety and reliability of their applications.

Why we LAV Starknet React

❤️ Starknet React is friendly to newbies to Web3! It’s designed for developers who are already familiar with common development patterns to pick it up quickly. Beyond this, Starknet can easily be configured to work with multiple RPCs.  Most importantly, it uses Lava’s Public RPC by default 🌋. ;-)

What we’d like to see!

We’d love to see Starknet React integrate LavaSDK and put some multi-chain madness in the mix. Right now, it is the premier tool for Starknet. We’d love to see it expand to do more cross-chain/interoperable functionality.

Start building on Starknet

In conclusion, Starknet React emerges as a powerful and efficient tool for developers venturing into the realm of decentralized applications on the Starknet platform. Its seamless integration with React, coupled with a suite of features designed to simplify complex blockchain functionalities, positions it as a valuable asset in the Web3 development toolkit.

Whether you are a seasoned developer in the blockchain space or just starting out, Starknet React offers a compelling blend of familiarity, innovation, and efficiency.For those eager to dive deeper and start leveraging the capabilities of Starknet React in your projects, a wealth of resources and comprehensive guides are available.

If you want to start building on Starknet with fast, reliable RPC, we offer a public RPC service that consolidates all providers into one endpoint. You can get the endpoint in Lava's Starknet Start Guide.