Skip to main content
The useEntity hook fetches entity data. Entities are sub-resources of customers, typically used for per-seat or per-resource billing.
Learn how to setup Autumn hooks in the Getting Started guide.

Parameters

entityId
string
required
The ID of the entity to retrieve.
queryOptions
UseQueryOptions
Optional TanStack Query options to customize caching and refetching behavior.

Returns

data

The entity object containing subscriptions, purchases, and balances for that entity.
import { useEntity } from "autumn-js/react";

export default function SeatDetails() {
  const { data, isLoading } = useEntity({ entityId: "seat_42" });

  if (isLoading) return <div>Loading...</div>;

  return (
    <div>
      <p>Name: {data?.name}</p>
      <p>Messages remaining: {data?.balances?.messages?.remaining}</p>
    </div>
  );
}

isLoading

Boolean indicating whether the entity data is currently being fetched.

error

Any error that occurred while fetching entity data.

refetch()

Function to manually refetch the entity data.