trees

Use when an app uses @pierre/trees to render or control a file tree, including React, vanilla JavaScript, SSR, web components, selection, search, rename, drag and drop, icons, git status, and themes.

Install
npx skills add 'https://github.com/pierrecomputer/pierre/tree/main/skills/trees'
Download bundle ↓
main · 1831817Scanned 2026-09-15

Contributors

GitHub-linked commit authors for this SKILL.md at the saved revision. Co-authors and history before file renames are not included.

File history ↗
View on GitHub
← Back to SKILL.md

Recipe: preload a file tree on the server

Create one payload and pass it to the React tree:

import { preloadFileTree } from '@pierre/trees/ssr';
import { FileTree, useFileTree } from '@pierre/trees/react';

const options = {
  id: 'project-files',
  paths: ['README.md', 'src/', 'src/index.ts'],
  initialExpansion: 'open' as const,
  initialVisibleRowCount: 8,
};

const preloadedData = preloadFileTree(options);

export function ProjectFiles() {
  const { model } = useFileTree(options);
  return (
    <FileTree
      model={model}
      preloadedData={preloadedData}
      style={{ height: 240 }}
    />
  );
}

For a direct HTML response, call serializeFileTreeSsrPayload(payload). Pass dom as the second argument when a DOM API inserts the complete markup string.

Referenced from SKILL.md