# Show a placeholder (https://0758e0c7.effetch-query.pages.dev/docs/queries/placeholders)

A detail page can show what the list already has while the detail loads.
`placeholder` returns `Option.some` of a value to show, or
`Option.none()` for nothing. On `api.query`, it gets the call's `params`
and `query`:

The examples import `todos.ts` from [Getting started](https://0758e0c7.effetch-query.pages.dev/docs/getting-started), and `entities.ts` from [Entities](https://0758e0c7.effetch-query.pages.dev/docs/mutations/entities).

```ts todo-detail.ts
import { Entity } from "@monarcode/effetch-query";

import { Todos } from "./entities.js";
import { api, getTodo } from "./todos.js";

export const todo = api.query(getTodo, {
  staleTime: "1 minute",
  // A list's copy, if one is cached, until the todo's own fetch settles.
  placeholder: ({ params }) => Entity.get(Todos, Number(params.id)),
});
```

`Entity.get` reads the newest cached copy of the todo
([Entities](https://0758e0c7.effetch-query.pages.dev/docs/mutations/entities)); any Effect that reads the cache works, such as
`Query.get` of a list. `Query.make` takes `placeholder` as an Effect, and
`Query.family` as a function of the member's argument. Keep it
synchronous, reading the cache: an asynchronous one shows only once it's
done, if the fetch hasn't settled first. If it dies, the defect is logged
and nothing shows.

The placeholder shows as a waiting `Success`, so `useSuspenseQuery`
doesn't suspend on it. Once the fetch settles, its value or its failure
replaces it. It's never cached: `Query.get`, `Query.update` and
`Query.fetch` don't see it, `QueryClient.dehydrate` doesn't send it, and
a query reading this one through `ctx.result` waits for the real value. A
server render doesn't show it.

To tell a placeholder from the query's own value, read `isPlaceholder`
from `useQueryState` ([Read a query as an object](https://0758e0c7.effetch-query.pages.dev/docs/react/as-object)).
It's true for the placeholder, and for the value `keepPrevious` keeps
from the query shown before, until the query's own value or failure
replaces it. A `paused` reader fetches nothing, so it keeps showing the
placeholder, not fetching, until it resumes:

```tsx
import { useQueryState } from "@monarcode/effetch-query/react";

import { todo } from "./todo-detail.js";

export function TodoTitleInput({ id }: { readonly id: number }) {
  const state = useQueryState(todo({ params: { id } }));

  if (state.status !== "success") {
    return null;
  }
  // Editing waits for the todo itself, not the list's copy.
  return (
    <input defaultValue={state.data.title} disabled={state.isPlaceholder} />
  );
}
```