API Reference

globby

User-friendly glob API built on fast-glob that also expands gitignore and directory patterns.

Official Documentation ↗
CompatibilityThis documentation covers version v16.2.4. Check the official docs for the latest API surface.

Installation

npmnpm install globby

Methods

globby adds convenience on top of fast-glob: gitignore awareness, directory expansion, and a stream API.

Key Features

  • gitignore: true merges repository ignore rules
  • expandDirectories converts dir patterns to contents
  • Sync, async, and stream entry points

Usage Notes

Pin a version and check the official docs for the API surface you depend on before upgrading.

API reference evidence

Fetched from official sources on 2026-11-08T19:11:00+08:00 via WebFetch https://raw.githubusercontent.com/sindresorhus/globby/main/index.d.ts.

FAQ

Does globby respect .gitignore?
Yes. Pass gitignore: true and it reads the nearest .gitignore files, merging them with any explicit ignore patterns.
Is globby a separate implementation?
No. It is a friendlier wrapper over fast-glob that adds gitignore, directory expansion, and array-based pattern handling.
How do I only match directories?
Set onlyDirectories: true for directories or onlyFiles: true for files; both are options forwarded to fast-glob.