SSR in Astro

Fetch LinkFox data in Astro frontmatter and render HTML on the server.

Astro page example

---
import { createLinkFoxClient } from '@linkfox/core';

const linkfox = createLinkFoxClient({
  apiKey: import.meta.env.LINKFOX_API_KEY,
});

const data = await linkfox.getSiteDelivery('game-father', {
  group: 'game',
  utmKey: 'ref',
  utmValue: 'astro',
});
---

<nav class="linkfox-inline">
  {data.items.map((item) => (
    <a href={item.url} target="_blank" rel="noreferrer">{item.name}</a>
  ))}
</nav>

Notes

  • Keep LINKFOX_API_KEY in server-only Astro env
  • Fetch in frontmatter, not in a browser script
  • Render plain HTML for best control and no client key exposure