# root

Root-directory detection using marker files for git roots, project roots, and workspace roots.

[`findGitRoot`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-findGitRoot) walks up from a starting path until it finds a `.git` directory. [`findProjectRoot`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-findProjectRoot) looks for the first ancestor containing a `package.json` (or another entry from [`ROOT_MARKERS`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-ROOT_MARKERS)). [`findWorkspaceRoot`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-findWorkspaceRoot) is similar but uses [`WORKSPACE_MARKERS`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-WORKSPACE_MARKERS) (Nx, Lerna, Rush, pnpm/Yarn/npm workspace declarations) so it stops at the monorepo root rather than at any individual package. [`findRootDirectory`](https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/#api-findRootDirectory) is the generalized helper that takes a custom marker list. The marker constants are exposed for downstream tools that need to extend or customize the search.

---

Canonical page: https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root/
This file: https://www.hyperfrontend.dev/docs/libraries/project-scope/project/root.md
Documentation index: https://www.hyperfrontend.dev/llms.txt
