npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@profplum700/etsy-react

v2.4.3

Published

React hooks for Etsy v3 API client

Readme

@profplum700/etsy-react

React hooks for the Etsy v3 API client. Simplify your Etsy integrations with powerful, type-safe React hooks.

Installation

npm install @profplum700/etsy-react @profplum700/etsy-v3-api-client

Quick Start

import React from 'react';
import { EtsyProvider, useShop, useListings, useUpdateListing } from '@profplum700/etsy-react';
import { EtsyClient } from '@profplum700/etsy-v3-api-client';

// Initialize client
const client = new EtsyClient({
  apiKey: process.env.ETSY_API_KEY,
  // ... other config
});

function App() {
  return (
    <EtsyProvider client={client}>
      <ShopDashboard />
    </EtsyProvider>
  );
}

function ShopDashboard() {
  const { data: shop, loading, error } = useShop('123');
  const { data: listings, hasMore, loadMore } = useListings('123', {
    state: 'active',
    limit: 25,
  });
  const { mutate: updateListing } = useUpdateListing();

  if (loading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;

  return (
    <div>
      <h1>{shop.title}</h1>
      <ListingGrid
        listings={listings}
        onUpdate={(id, updates) =>
          updateListing({ shopId: '123', listingId: id, updates })
        }
      />
      {hasMore && <button onClick={loadMore}>Load More</button>}
    </div>
  );
}

Hooks

Context Hooks

useEtsyClient()

Get the Etsy client instance from context.

const client = useEtsyClient();

Query Hooks

useShop(shopId, options?)

Fetch shop details.

const { data, loading, error, refetch } = useShop('123');

useListings(shopId, listingsOptions?, queryOptions?)

Fetch shop listings with pagination support.

const {
  data: listings,
  loading,
  error,
  hasMore,
  loadMore,
  currentPage,
  totalPages,
} = useListings('123', {
  state: 'active',
  limit: 25,
  sort_on: 'created',
  sort_order: 'desc',
});

useListing(listingId, options?)

Fetch a single listing.

const { data, loading, error } = useListing('456');

useReceipts(shopId, receiptsOptions?, queryOptions?)

Fetch shop receipts with pagination.

const {
  data: receipts,
  loading,
  hasMore,
  loadMore,
} = useReceipts('123', {
  was_paid: true,
  limit: 25,
});

useReceipt(shopId, receiptId, options?)

Fetch a single receipt.

const { data, loading } = useReceipt('123', '789');

Mutation Hooks

useUpdateListing(options?)

Update a listing.

const { mutate, loading, error } = useUpdateListing({
  onSuccess: (data) => console.log('Updated:', data),
  onError: (error) => console.error('Error:', error),
});

// Use it
mutate({
  shopId: '123',
  listingId: '456',
  updates: { title: 'New Title', price: 29.99 },
});

useCreateDraftListing(options?)

Create a new draft listing.

const { mutate } = useCreateDraftListing();

mutate({
  shopId: '123',
  params: {
    quantity: 1,
    title: 'My Product',
    description: 'Product description',
    price: 19.99,
    who_made: 'i_did',
    when_made: '2020_2024',
    taxonomy_id: 123,
  },
});

useDeleteListing(options?)

Delete a listing.

const { mutate } = useDeleteListing();

mutate({ listingId: '456' });

useUpdateInventory(options?)

Update listing inventory.

const { mutate } = useUpdateInventory();

mutate({
  listingId: '456',
  updates: {
    products: [
      {
        sku: 'SKU-001',
        offerings: [{ price: 29.99, quantity: 10 }],
      },
    ],
  },
});

useUploadListingImage(options?)

Upload an image to a listing.

const { mutate, loading } = useUploadListingImage();

mutate({
  shopId: '123',
  listingId: '456',
  image: imageFile, // File or Buffer
  rank: 1,
});

Advanced Usage

Auto-refetch on Interval

const { data } = useReceipts('123', { was_paid: false }, {
  refetchInterval: 60000, // Refetch every minute
});

Refetch on Window Focus

const { data } = useShop('123', {
  refetchOnWindowFocus: true,
});

Conditional Queries

const { data } = useShop(shopId, {
  enabled: !!shopId, // Only fetch when shopId is available
});

Optimistic Updates

const { mutate } = useUpdateListing({
  onSuccess: (updatedListing) => {
    // Update local state optimistically
    setListings((prev) =>
      prev.map((listing) =>
        listing.listing_id === updatedListing.listing_id
          ? updatedListing
          : listing
      )
    );
  },
});

TypeScript Support

All hooks are fully typed with TypeScript. The package includes comprehensive type definitions.

import type {
  UseQueryOptions,
  UseQueryResult,
  UseMutationOptions,
  UseMutationResult,
  UsePaginatedQueryResult,
} from '@profplum700/etsy-react';

API

Query Options

interface UseQueryOptions<T> {
  enabled?: boolean;
  refetchInterval?: number;
  refetchOnWindowFocus?: boolean;
  onSuccess?: (data: T) => void;
  onError?: (error: Error) => void;
}

Mutation Options

interface UseMutationOptions<TData, TVariables> {
  onSuccess?: (data: TData, variables: TVariables) => void;
  onError?: (error: Error, variables: TVariables) => void;
  onSettled?: (data: TData | undefined, error: Error | null, variables: TVariables) => void;
}

License

MIT

Related Packages