React SDK

useObject

Query what an object key resolves to

This query resolves a single object key under an account. Returns null when nothing is bound under it.

Example

import { useObject } from "@shelby-protocol/react";

function ObjectDetails({ owner, key }: { owner: string; key: string }) {
  const { data: object, isLoading, error } = useObject({ owner, key });

  if (isLoading) return <div>Loading...</div>;
  if (error) return <div>Error: {error.message}</div>;
  if (!object) return <div>Object not found</div>;

  return (
    <div>
      <h2>{object.key}</h2>
      <p>Size: {object.plaintextSize} bytes</p>
      <p>
        Committed: {new Date(object.committedAtMicros / 1000).toLocaleString()}
      </p>
      <p>Resolves to: {object.content.kind}</p>
    </div>
  );
}

Parameters

Prop

Type

React Query Options

Prop

Type

Return Value

Prop

Type