Skip to main content

Overview

useFetchEntityByShortId returns a function that fetches an entity by its shortId — the auto-generated short identifier that Replyke assigns to every entity. Short IDs are useful for building readable sharing URLs.

Usage Example

import { useFetchEntityByShortId } from "@replyke/react-js";
import { useParams } from "react-router-dom";

function SharePage() {
  const { shortId } = useParams<{ shortId: string }>();
  const fetchEntity = useFetchEntityByShortId();

  const load = async () => {
    const entity = await fetchEntity({ shortId });
    console.log(entity);
  };

  return <button onClick={load}>Load Shared Entity</button>;
}

Parameters

shortId
string
required
The short ID to look up. This is the value from entity.shortId.
include
string | string[]
Optional. Populate related fields. Accepted values: "user", "space", "topComment", "saved", "files".

Returns

Entity
Entity
The fetched entity. See Entity data model.