# Showcase widget

Embed portfolios, galleries, reviews, and blog posts on your site.

## Overview

The inFlow showcase widget renders SSR-generated HTML for grid views and individual post pages. It supports blog posts, project galleries, portfolios, and review collections — all managed in your inFlow dashboard and rendered on your own site with automatic revalidation.

The widget is a **server component** — it fetches HTML from the inFlow API at request time (with ISR caching) and renders it inline. No client-side JavaScript is needed for the base rendering.

## Declarative embed

Place a `<div>` with `data-tks-showcase` in your HTML. The toolkit script auto-detects it and renders the showcase inline.

```html
<!-- Load the toolkit (once per page) -->
<script
  src="https://api.inflow.build/toolkit.v2.js"
  data-tks-key="pk_..."
  data-tks-environment="your_environment_id"
  async
></script>

<!-- Showcase grid will render here -->
<div data-tks-showcase="67a1b2c3d4e5f6a7b8c9d0e1"></div>
```

## React / Next.js embed (SSR)

For Next.js apps, use the `InflowShowcase` server component. It fetches SSR output from the inFlow API with 5-minute ISR revalidation.

```tsx
// app/blog/page.tsx
import { InflowShowcase } from "@/components/embed/InflowShowcase";

export default async function BlogPage() {
  return (
    <InflowShowcase
      showcaseId="67a1b2c3d4e5f6a7b8c9d0e1"
      publicKey="pk_..."
    />
  );
}
```

## Single post with comments

For a blog post detail page, pass `postSlug` to render a single post. You can also nest `ShowcaseComments` to add a comment section.

```tsx
// app/blog/[slug]/page.tsx
import { InflowShowcase } from "@/components/embed/InflowShowcase";
import { ShowcaseComments } from "@/components/embed/ShowcaseComments";

export default async function PostPage({ params }) {
  return (
    <InflowShowcase
      showcaseId="67a1b2c3d4e5f6a7b8c9d0e1"
      publicKey="pk_..."
      postSlug={params.slug}
    >
      <ShowcaseComments
        showcaseId="67a1b2c3d4e5f6a7b8c9d0e1"
        postSlug={params.slug}
        publicKey="pk_..."
      />
    </InflowShowcase>
  );
}
```

## Theme options

The showcase widget supports four theme modes via the `theme` prop:

| Value | Behavior |
| --- | --- |
| auto (default) | Inherits your site's current text color. Cards and borders derive from it via color-mix(). Follows light/dark mode automatically. |
| light | Always renders cards with a light palette, regardless of your site theme. |
| dark | Always renders cards with a dark palette, regardless of your site theme. |
| showcase | Uses the showcase's saved theme from the inFlow dashboard (colors and typography chosen in the builder). |

```tsx
<InflowShowcase
  showcaseId="..."
  publicKey="..."
  theme="auto"    // or "light", "dark", "showcase"
/>
```

## Configuration

| Prop | Type | Description |
| --- | --- | --- |
| showcaseId | string | Showcase ID from your dashboard (required) |
| publicKey | string | Your pk_… public key (required) |
| postSlug | string | Single post slug for detail pages |
| pathPrefix | string | Base path for links (e.g. '/blog') |
| apiBase | string | API origin (default "https://api.inflow.build") |
| theme | string | "auto" \| "light" \| "dark" \| "showcase" |
| className | string | Extra CSS classes |
| children | ReactNode | Nested content (e.g. ShowcaseComments) |

## Caching (ISR)

`InflowShowcase` uses Next.js ISR with a 5-minute revalidation window. Blog posts, portfolio items, and reviews update automatically within 5 minutes of changes in your dashboard — no manual redeploy needed.

```ts
// Internal fetch with ISR
const res = await fetch(url, {
  headers: { Authorization: `Bearer ${publicKey}` },
  next: { revalidate: 300 }, // 5 minutes
});
```
