# C cohort retention 1

> Weekly retention — signup cohorts by week

A shadcn/ui block from the [@cnippet](https://ui.cnippet.dev/?utm_source=shadcn.exchange) registry, listed on [shadcn.exchange](https://shadcn.exchange/r/cnippet/c-cohort-retention-1).

- Page, with a live preview: https://shadcn.exchange/r/cnippet/c-cohort-retention-1
- Screenshot: https://shadcn.exchange/shot/cnippet/c-cohort-retention-1/light.png
- Registry item: https://ui.cnippet.dev/r/c-cohort-retention-1.json
- Categories: cohort retention
- Listed: 2026-10-27, source last changed 2026-10-27

## Install

```bash
npx shadcn@latest add https://shadcn.exchange/r/cnippet/c-cohort-retention-1.json
```

Run it in a project that has shadcn/ui set up. It adds the files below and installs what they depend on.

## Dependencies

- Registry items: `@cnippet/cohort-retention`, `@cnippet/chart-card`

## Files

### `registry/default/chart-variants/c-cohort-retention-1.tsx`

```tsx
"use client";

import { ChartCard } from "@/registry/default/charts/chart-card";
import { CohortRetention } from "@/registry/default/charts/cohort-retention";

const cohorts = ["Sep 1", "Sep 8", "Sep 15", "Sep 22", "Sep 29", "Oct 6"];
const sizes = [1204, 1131, 1342, 1288, 1410, 1376];

// Deterministic weekly retention: steep drop in week 1, then a slow decline.
// Newer cohorts haven't reached the later weeks yet.
const data = cohorts.map((cohort, c) => ({
  cohort,
  size: sizes[c] ?? 0,
  values: Array.from({ length: cohorts.length - c }, (_, w) =>
    w === 0 ? 1 : +(0.58 * 0.88 ** (w - 1) + c * 0.012).toFixed(3),
  ),
}));

export default function WeeklyRetention() {
  return (
    <ChartCard
      className="max-w-2xl"
      description="Share of each weekly signup cohort still active, by week since signup"
      title="Weekly retention"
    >
      <CohortRetention data={data} periodLabel={(w) => `W${w}`} />
    </ChartCard>
  );
}
```
