@linagee/lnr-ethers-react
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

Lnr Ethers React

npm npm bundle size npm

GitHub GitHub pull requests

code style: prettier

Requirements

  • React >= 18.0.0

Installation

Full documentation can be found here docs.linagee.app

# with npm
npm install @linagee/lnr-ethers-react

# with yarn
yarn add @linagee/lnr-ethers-react

Setup

Set LnrConfigProvider as a wrapper for your app

Example:

import { AppProps } from 'next/app';
import { ethers } from 'ethers';
import { LnrConfigProvider } from '@linagee/lnr-ethers-react';

function MyApp({ Component, pageProps }: AppProps) {
    const config = {
        provider: new ethers.providers.AlchemyProvider(1, process.env.REACT_APP_ALCHEMY_API
        ),
    };

    return (
        <LnrConfigProvider config={config}>
            <Component {...pageProps} />
        </LnrConfigProvider>
    );
}

export default MyApp;

You need to set REACT_APP_ALCHEMY_API in your .env file. You can set any provider you want, but we recommend using Alchemy.


Usage

Use the hooks in your components to get the data you need.

Example:

import React from "react";
import { useLnrGetAddress } from "@linagee/lnr-ethers-react";

function MyComponent() {
  const name = "0xhal.og";
  const { address, error, hasError, loading } = useLnrGetAddress(name);

  if (loading) {
    return <div>Loading...</div>;
  }

  if (hasError) {
    return <div>Error: {error}</div>;
  }

  return (
    <div>
      <h2>Name: {name}</h2>
      <p>Address: {address}</p>
    </div>
  );
}

export default MyComponent;

Readme

Keywords

Package Sidebar

Install

npm i @linagee/lnr-ethers-react

Weekly Downloads

1

Version

1.3.0

License

MIT

Unpacked Size

115 kB

Total Files

48

Last publish

Collaborators

  • chriton
  • mklnr