Catalog npm
PACKAGE EXPLORERView in registry

@0xflair/react-coingecko

npm

React hooks to get prices of cryptocurrency coins and tokens from CoinGecko.

Versions collected383
Direct dependencies10From release 0.123.2
Last observed20 Oct, 23:19 UTC

README

Current package documentation

Flair SDK: react-coingecko

React hooks to get prices of cryptocurrency coins and tokens from CoinGecko.

Getting Started

Installation

  1. Install the package:

    npm install @0xflair/react-coingecko
    
  2. Install peer dependencies:

    npm install axios
    
    # if visual components needed:
    npm install tailwindcss @headlessui/react @heroicons/react @tailwindcss/aspect-ratio
    
  3. Configure tailwind.config.js (Tailwind v3) to scan SDK for classes (if visual components needed):

    module.exports = {
      purge: [
        "./public/**/*.html",
        "./src/**/*.{js,jsx,ts,tsx,vue}",
    
        // This line tells Tailwind to look into SDK files
        "./node_modules/@0xflair/**/*.{js,jsx,ts,tsx,vue}",
      ],
      content: ["./src/**/*.{js,jsx,ts,tsx}"],
      plugins: [
        // These plugins are used in this package
        require("@tailwindcss/forms"),
        require("@tailwindcss/aspect-ratio"),
      ],
    };
    
  4. Configure the React provider:

    const cryptoPricesConfig = {
      coinGecko: {
        apiKey: "xxxx",
        symbols: ["ethereum", "matic-network"],
      },
    };
    
    const App = () => {
      return (
        <div className="app">
          <CoinGeckoProvider config={cryptoPricesConfig}>
            <HookExample />
          </CoinGeckoProvider>
        </div>
      );
    };
    

Usage

Simple Price

import { CryptoPrice, CryptoUnits } from "@0xflair/react-coingecko";

function App() {
  return (
    <>
      <CryptoPrice value='0.06' unit={CryptoUnits.ETHER} />
    </>
  );

Price Hook

import { useCryptoPrice } from "@0xflair/react-coingecko";

function App() {
  const [{data, error, loading}, fetchPrice] = useCryptoPrice({
    symbol: 'ethereum'
  });

  return (
    <ul>
        <li>Price of Ether: {data.usd} USD</li>
        <li>Loading: {loading ? 'Yes...' : 'Idle'}</li>
        <li>Error: {error}</li>
    </ul>
  );

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Versions 383

Collected releases
VersionPublishedDirect dependenciesOpen version
0.123.2Registry latest27 Nov 202210
0.123.112 Nov 202210
0.123.08 Nov 202210
0.122.228 Oct 202210
0.122.128 Oct 202210
0.122.028 Oct 202210
0.121.227 Oct 202210
0.121.124 Oct 202210
0.121.020 Oct 202210
0.120.1120 Oct 202210
0.120.1019 Oct 202210
0.120.910 Oct 202210
0.120.810 Oct 202210
0.120.710 Oct 202210
0.120.63 Oct 202210
0.120.53 Oct 202210
0.120.43 Oct 202210
0.120.33 Oct 202210
0.120.23 Oct 202210
0.120.130 Sept 202210

Package advisories

0
No matching advisories collected

This describes our collected data; it is not a security assessment.

Repository

PENDING
0xflair/typescript-sdk

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 23:18 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package:37c8edfd4f331902983bc2c2a95a2fad3a447a0163128ae9284d39cb438ee7c5