RoomKitFrontend
useExamSessions
List exam sessions with filters and pagination
Overview
useExamSessions fetches a paginated list of exam sessions. It calls GET {apiUrl}/exams.
import { useExamSessions } from '@roomkit/react';Usage
function ExamList({ cohortId }: { cohortId: string }) {
const { data, isLoading } = useExamSessions({
filters: {
cohortId,
startsAt: new Date('2026-07-01'),
endsAt: new Date('2026-07-31'),
},
pagination: { limit: 20 },
});
if (isLoading) return <div>Loading exams...</div>;
return (
<ul>
{data?.items.map((session) => (
<li key={session.id}>
{session.cohortId} — Layout: {session.layoutType} — Capacity: {session.requiredCapacity}
</li>
))}
</ul>
);
}UseExamSessionsOptions
interface UseExamSessionsFilters {
cohortId?: string;
startsAt?: Date;
endsAt?: Date;
layoutType?: string;
}
interface UseExamSessionsOptions {
filters?: UseExamSessionsFilters;
pagination?: Pagination;
enabled?: boolean;
onSuccess?: (data: PaginatedResult<ExamSession>) => void;
onError?: (error: Error) => void;
}| Option | Type | Required | Description |
|---|---|---|---|
filters | UseExamSessionsFilters | No | Filter by cohort, time range, layout type |
pagination | Pagination | No | { cursor?, limit } |
enabled | boolean | No | Set to false to skip the request |
onSuccess | (data) => void | No | Called when the request succeeds |
onError | (error) => void | No | Called when the request fails |
Return Value
| Field | Type | Description |
|---|---|---|
data | PaginatedResult<ExamSession> | null | Paginated exam sessions |
isLoading | boolean | true while the request is in flight |
error | Error | null | The error if the request failed |
refetch | () => Promise<void> | Manually re-fetch the data |
API Endpoint
GET {apiUrl}/exams?cohortId=...&startsAt=...&endsAt=...&layoutType=...