SHELL_SITE

tcmts.cli.test.e2e.prod.SHELL_SITE · #fvmmlmbg · term · runs anywhere

A page with a part that renders the same each time, and a slow live part (it reads and writes a table).

export const SHELL_SITE = `// tcm: namespace news
import { Suspense } from "react";
import { table } from "#codebase/lib/server";
import { useAppLinks } from "#codebase/news/lib/react";

export const views = table<{ at: number }>("views");

export async function Headline() {
  return <h1>News</h1>;
}

export async function Views() {
  await views.insert({ at: 1 });
  await new Promise((r) => setTimeout(r, 400));
  return <p className="views">{(await views.find()).length} views</p>;
}

export function App() {
  useAppLinks();
  return (
    <main>
      <Headline />
      <Suspense fallback={<p className="views">counting</p>}>
        <Views />
      </Suspense>
    </main>
  );
}
`

used by