Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/ephraimduncan/minimal.so/llms.txt

Use this file to discover all available pages before exploring further.

Endpoint

client.bookmark.refetch(input)
Defined in: server/procedures/bookmarks.ts:181

Authentication

This endpoint requires authentication. See Authentication for details.

Request

id
string
required
ID of the bookmark to refetch metadata for

Input Schema

{
  id: string;
}

Response

Returns the updated bookmark object with refreshed metadata.
id
string
required
The bookmark ID
title
string
required
Updated title from the page’s metadata
favicon
string | null
Updated favicon URL fetched from the page
url
string | null
The bookmark’s URL (unchanged)
type
'link' | 'color' | 'text'
required
Bookmark type
color
string | null
Color value (unchanged)
groupId
string
required
Group ID (unchanged)
userId
string
required
Owner’s user ID
createdAt
Date
required
Original creation timestamp
updatedAt
Date
required
Updated timestamp (automatically set to current time)

Examples

Refetch Single Bookmark

import { orpc } from '@/lib/orpc';

function RefetchButton({ bookmarkId }: { bookmarkId: string }) {
  const refetchMutation = orpc.bookmark.refetch.useMutation();

  const handleRefetch = async () => {
    const updated = await refetchMutation.mutateAsync({
      id: bookmarkId,
    });

    console.log('Updated title:', updated.title);
    console.log('Updated favicon:', updated.favicon);
  };

  return (
    <button
      onClick={handleRefetch}
      disabled={refetchMutation.isPending}
    >
      {refetchMutation.isPending ? 'Refetching...' : 'Refresh Metadata'}
    </button>
  );
}

Refetch with Error Handling

import { client } from '@/lib/orpc';
import { ORPCError } from '@orpc/client';

async function refetchBookmarkMetadata(bookmarkId: string) {
  try {
    const bookmark = await client.bookmark.refetch({ id: bookmarkId });
    return { success: true, bookmark };
  } catch (error) {
    if (error instanceof ORPCError) {
      if (error.code === 'NOT_FOUND') {
        return { success: false, error: 'Bookmark not found or has no URL' };
      }
    }
    throw error;
  }
}

Server-Side Refetch

import { serverClient } from '@/lib/orpc.server';

async function refreshBookmark(bookmarkId: string) {
  const bookmark = await serverClient.bookmark.refetch({
    id: bookmarkId,
  });

  return {
    id: bookmark.id,
    title: bookmark.title,
    favicon: bookmark.favicon,
  };
}

Batch Refetch Multiple Bookmarks

import { client } from '@/lib/orpc';

async function refetchAllBookmarks(bookmarkIds: string[]) {
  const results = await Promise.allSettled(
    bookmarkIds.map(id => client.bookmark.refetch({ id }))
  );

  const succeeded = results.filter(
    r => r.status === 'fulfilled'
  ).length;

  console.log(`Refetched ${succeeded}/${bookmarkIds.length} bookmarks`);
}

Implementation

From server/procedures/bookmarks.ts:181:
export const refetchBookmark = authed
  .input(z.object({ id: z.string() }))
  .handler(async ({ context, input }) => {
    const existing = await db.bookmark.findFirst({
      where: { id: input.id, userId: context.user.id },
    });

    if (!existing || !existing.url) {
      throw new ORPCError("NOT_FOUND", {
        message: "Bookmark not found or has no URL",
      });
    }

    const metadata = await getUrlMetadata(existing.url);

    const bookmark = await db.bookmark.update({
      where: { id: input.id, userId: context.user.id },
      data: {
        title: metadata.title || existing.title,
        favicon: metadata.favicon,
      },
    });

    return bookmark;
  });

Behavior

Metadata Fetching

The endpoint fetches fresh metadata from the bookmark’s URL:
  1. Verifies the bookmark exists and has a URL
  2. Calls getUrlMetadata() to fetch the page’s title and favicon
  3. Updates the bookmark with the new metadata
  4. Falls back to the existing title if fetching fails

Title Fallback

If the metadata fetch fails or returns no title:
title: metadata.title || existing.title
The existing title is preserved rather than being cleared.

Favicon Update

The favicon is always updated, even if null:
favicon: metadata.favicon
This ensures outdated favicons are removed if they’re no longer available.

URL Requirement

Only bookmarks with a URL can be refetched. Color and text bookmarks will return a NOT_FOUND error:
if (!existing || !existing.url) {
  throw new ORPCError("NOT_FOUND", {
    message: "Bookmark not found or has no URL",
  });
}

Use Cases

When to Refetch

  • Page title has changed since the bookmark was created
  • Favicon has been updated or is missing
  • Original metadata fetch failed during creation
  • User wants to refresh stale metadata

When Not to Refetch

  • Bookmark type is color or text
  • URL is broken or no longer accessible
  • Metadata is manually customized and shouldn’t be overwritten

Errors

NOT_FOUND
error
The bookmark doesn’t exist, doesn’t belong to the user, or has no URL (e.g., color/text type bookmark).
UNAUTHORIZED
error
User is not authenticated.

Notes

  • Metadata fetching may take several seconds depending on the target site’s response time
  • The operation is safe to retry if it fails
  • Only link-type bookmarks with valid URLs can be refetched
  • The updatedAt timestamp is automatically updated

Build docs developers (and LLMs) love