Reference · React

useRecord(uri, options?)

Next release: this page describes techne-sdk/types, which is not in techne-sdk 0.3.4 yet. With techne-sdk 0.3 today shows the released API.

React hooktechne-sdk/reactIn the SDK, techne.get

One record by its address, as a React read. data is its item, or null when nothing valid is there.

The URI sets the type. A Uri<Place> answers a place, and a bare string answers unknown. A null or undefined URI reads nothing, so you can pass one that is not there yet.

Parameters

NameTypeWhat it is
urirequiredstring | null | undefinedThe record's at:// address. Usually an item's uri from another read.
options.prefer'mine'The signed-in person's own version, when they have one. Else the curated record.
options.exactbooleanExactly the record at the URI, never another copy.
options.include'valid' | 'all''valid' is the default, and a record that is not valid answers null. 'all' answers any verdict.
options.enabledbooleanfalse holds the read.

Also subscribed: false, to keep a hidden screen off the cache's updates.

Returns TanStack's query result

NameTypeWhat it is
dataValidItem<T> | null | undefinedThe item. null when nothing is there, undefined until read.
isPendingbooleanTrue until there is data.
errorError | nullWhy the read failed, if it did.
refetch() => PromiseRead again now.

Its key is ['techne', 'record', uri, options, did]. useRecord never carries versions. useVersions does.

A place, by the address in the URL

Place.uri types the string, so place.record is a Place. It checks nothing.

The same read without React

useRecord(uri, options) is useQuery(techne.getOptions(uri, options)).

Calls commons.getVersions, or query.getRecords → for an exact or private record