Epicenter
Local-first, open source apps
Next.js streams a route in chunks, so the page shows up before every request finishes.
Wrap a slow part of the page in a Suspense boundary and React sends the fallback first. When the data resolves, the finished HTML streams into the same response and replaces the fallback, with no extra request from the browser. Server Components help here, because their code never ships to the browser.
A loading.tsx file does the same for a whole route segment. It all runs over chunked transfer encoding, so there is nothing extra to set up.
Inline Citation is a source that sits in the sentence it supports. It is a Hover Card on a Button.
To show a list of sources after the reply, use Sources.
Installation
Inline Citation is built with the Hover Card and Button components.
Usage
<HoverCard.Root openDelay={10} closeDelay={100}>
<HoverCard.Trigger>
{#snippet child({ props })}
<Button {...props} variant="secondary" size="xs">
{hostname}
</Button>
{/snippet}
</HoverCard.Trigger>
<HoverCard.Content class="flex w-64 flex-col gap-1">
<div class="font-medium">{title}</div>
<a href={url} target="_blank" rel="noreferrer">
{hostname}
<span class="sr-only"> (opens in a new tab)</span>
</a>
</HoverCard.Content>
</HoverCard.Root> AI SDK
A source-url part is the citation. Set sendSources: true on toUIMessageStreamResponse(), or write the part yourself.
writer.write({
type: "source-url",
sourceId: "shadcn",
url: "https://ui.shadcn.com",
title: "shadcn/ui",
}); const sources = $derived(
message.parts.filter((part) => part.type === "source-url")
); title is optional. Fall back to the URL's hostname.