Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@spinamp/spinamp-hooks

Package Overview
Dependencies
Maintainers
2
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@spinamp/spinamp-hooks

Set of react hooks for fetching data from spinamp pipeline built on top of react-query and spinamp-sdk.

  • 0.0.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

@spinamp/spinamp-hooks

Spinamp-Hooks is a set of react hooks for fetching data from Spindex, Spinamp's growing index of the growing web3 music ecosystem. It provides hooks for music nft activity, music content, metadata and playlists.

It is built on top of react-query and spinamp-sdk. It gives quick and easy access to data and handles all loading & refetching with the power of react-query.

Installation

The package can be installed using yarn or npm:

yarn add @spinamp/spinamp-hooks

or

npm i @spinamp/spinamp-hooks

Usage

The only thing required to make the lib work is to wrap whole app with the SpinampProvider component. Once it's done, all hooks can be used in all children components:

import {SpinampProvider, useAllTracksQuery} from "@spinamp/spinamp-hooks";

function App() {
  return (
    // Wrap whole app with the SpinampProvider
    <SpinampProvider>
      <TracksList />
    </SpinampProvider>
  )
}

function TracksList() {
  const {tracks, isLoading, isError, refetch} = useAllTracksQuery();

  if (isLoading) {
    return <p>Loading!</p>;
  }

  if (isError) {
    return (
      <div>
        <p>Ups! Something went wrong</p>
        <button onPress={() => refetch()}>Try again</button>
      </div>
    );
  }

  return (
    <div>
      <p>All tracks list!</p>
      <ul>
        {tracks.map(track => (
          <li key={track.id}>{track.title}</li>
        ))}
      </ul>
    </div>
  );
}

render(<App />, document.getElementById('root'));

For further usage examples and comprehensive API Reference, see the documentation.

FAQs

Package last updated on 23 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc