---
title: React Turnstile - Managing widget status
---

# Managing widget status

You can use the callbacks `onError`, `onExpire` and `onSuccess` to manage the widget status.

```tsx
import { Turnstile } from "@marsidev/react-turnstile";

type Status = "error" | "expired" | "solved";

export default function Widget() {
  const [status, setStatus] = React.useState<Status | null>(null);

  return (
    <Turnstile
      siteKey="{{ siteKey }}"
      onError={() => setStatus("error")}
      onExpire={() => setStatus("expired")}
      onSuccess={() => setStatus("solved")}
    />
  );
}
```
