Astro

Choose prerendered public pages or on-demand rendering for fresh and personalized Cavuno data.

Astro prerenders pages by default. That works for public Cavuno content when build-time freshness is acceptable. Use on-demand rendering for frequently changing catalogs, authenticated pages, and any route that reads or writes a session cookie.

Create the client

ts
import { createBoardClient } from '@cavuno/board';
export const board = createBoardClient({
board: import.meta.env.PUBLIC_CAVUNO_BOARD,
auth: { storage: 'nostore' },
});

Render a public jobs page on demand

astro
---
export const prerender = false;
import { board } from '../lib/cavuno';
const page = Math.max(1, Number(Astro.url.searchParams.get('page') ?? '1'));
const limit = 20;
const jobs = await board.jobs.list({
query: Astro.url.searchParams.get('query') ?? undefined,
limit,
offset: (page - 1) * limit,
});
---
<main>
<h1>Open roles</h1>
<ul>
{jobs.data.map((job) => <li>{job.title} at {job.company.name}</li>)}
</ul>
</main>

Use a supported server adapter before setting prerender = false. If the catalog can be stale until the next build, omit that export and let Astro generate static HTML.

Return a native 404

astro
---
import { isNotFound } from '@cavuno/board';
import { board } from '../../../lib/cavuno';
try {
const job = await board.jobs.retrieve(Astro.params.jobSlug!);
} catch (error) {
if (isNotFound(error)) {
return new Response(null, { status: 404 });
}
throw error;
}
---

Use the canonical route /companies/[companySlug]/jobs/[jobSlug] and redirect a mismatched company segment to the job’s canonical path.

Keep personalized routes on demand

Candidate, employer, saved-job, application, and messaging pages must not be prerendered. Read the application’s httpOnly cookie from Astro.cookies, pass authorization per SDK call, and return private/no-store cache headers.

Verify the Astro rendering mode

  1. Inspect the production build output and confirm which routes are prerendered.
  2. Deploy the chosen adapter and verify on-demand jobs reflect a newly published role without rebuilding.
  3. Open an invalid job slug and confirm the response status is 404.
  4. Test two authenticated sessions and inspect cache headers for private routes.
  5. Inspect raw HTML for the job metadata and structured data required by search engines.

Continue with SEO and structured data for public pages and SSR sessions for personalized routes.