Skip to main content

useApiAuthAuditLogs

The useApiAuthAuditLogs hook fetches API auth audit events and pagination metadata.

Parameters

options.limit
number
Maximum events per page.
options.cursor
string
Pagination cursor.
options.outcome
string
Filter by outcome.
options.key_id
string
Filter by key ID.
options.start_date
string
ISO start date.
options.end_date
string
ISO end date.

Return Value

logs
ApiAuditLogsResponse['data']
Audit log items.
limit
number
Applied limit.
has_more
boolean
Whether more data exists.
next_cursor
string | undefined
Cursor for next page.
loading
boolean
Whether request is in progress.
error
unknown
Error from the latest request.
refetch
() => void
Revalidate logs.

Example

import { useApiAuthAuditLogs } from "@wacht/react-router";

function AuditLogList() {
  const { logs, has_more, next_cursor } = useApiAuthAuditLogs({ limit: 50 });

  return (
    <div>
      <pre>{JSON.stringify(logs, null, 2)}</pre>
      {has_more && <p>Next cursor: {next_cursor}</p>}
    </div>
  );
}