> ## Documentation Index
> Fetch the complete documentation index at: https://docs.simpu.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Templates Hooks

Hooks for fetching and managing email templates.

## useGetTemplates

The `useGetTemplates` hook fetches email templates, allowing you to retrieve a list of templates and their details.

<a target="_blank" href="https://tanstack.com/query/latest/docs/framework/react/reference/useQuery" className="border text-sm inline-block w-auto h-10 flex justify-self-start items-center justify-center text-center px-4 rounded-md border-gray-950/10 dark:border-white/10">
  <span>API Reference</span>
</a>

### Usage

```typescript theme={null}
import { useGetTemplates } from "@simpu/mail-sdk";

function TemplatesPage() {
  const { data, isPending, isError } = useGetTemplates();

  if (isPending) {
    return <div>Loading...</div>;
  }

  if (isError) {
    return <div>Error loading templates</div>;
  }

  return (
    <div>
      {data.map((template) => (
        <div key={template.id}>
          <h3>{template.name}</h3>
        </div>
      ))}
    </div>
  );
}
```

## useGetTemplate

The `useGetTemplate` hook fetches a specific email template by its ID, allowing you to retrieve its details.

<a target="_blank" href="https://tanstack.com/query/latest/docs/framework/react/reference/useQuery" className="border text-sm inline-block w-auto h-10 flex justify-self-start items-center justify-center text-center px-4 rounded-md border-gray-950/10 dark:border-white/10">
  <span>API Reference</span>
</a>

### Usage

```typescript theme={null}
import { useGetTemplate } from "@simpu/mail-sdk";

function TemplatesPage() {
  const { data, isPending, isError } = useGetTemplate("1234");

  if (isPending) {
    return <div>Loading...</div>;
  }

  if (isError) {
    return <div>Error loading template</div>;
  }

  return (
    <div>
      {data.map((template) => (
        <div key={template.id}>
          <h3>{template.name}</h3>
        </div>
      ))}
    </div>
  );
}
```

### Parameters

```typescript theme={null}
interface Params {
  id: string;
}
```
