# useResendSeconds

Returns the whole seconds left until `resendAvailableAt`, ticking every second, clamped between `0` and `maxSeconds`. Call it as `useResendSeconds(resendAvailableAt, maxSeconds)`. Returns `0` when `resendAvailableAt` is `undefined`.

## Use for

- the seconds left on a resend cooldown, for display
- a "Resend code in 30s" label

## Practices

- Do: Keep `resendAvailableAt` in the machine, and derive the seconds in the view with this hook.
- Don't: Count seconds down in state or a machine. Store the timestamp instead.

## Examples

### A resend label

```tsx
const seconds = useResendSeconds(resendAvailableAt, 30);
```

## Related

- [useNow](/docs/hooks/use-now.md)
