useThreadRouting
Unpublished development API. This package is under development and is not available as a published release.
Keeps the active thread in the URL, the React counterpart of Angular
injectThreadRouting. The URL is the source of truth: the thread is restored
on load, selecting one pushes a history entry, back and forward are followed,
and a thread that exists rejects is replaced with the bare URL. The server
render and hydration read no URL and report no thread.
import { useThreadRouting } from '@threadplane/react/chat';Declaration · overload 1
export declare function useThreadRouting(options?: ThreadRoutingOptions): ThreadRouting;Parameters
options· optionalThreadRoutingOptions
Returns
ThreadRoutingExamples
const { threadId, setThreadId } = useThreadRouting({
exists: (id) => client.threads.get(id).then(() => true, () => false),
});
return <ThreadList threads={threads} activeThreadId={threadId} onSelect={setThreadId} />;