---
title: "getFlatTree"
description: "Return every node in depth-first reading order."
canonical: "https://www.qino.works/docs/api/tree/get-flat-tree"
---

# getFlatTree

> Return every node in depth-first reading order.

Walks the tree and flattens it depth-first, so a section comes right before its children.

```ts title="src/app/docs/[...slug]/page.tsx"
const nodes = await docsTree.getFlatTree();
// introduction, guides, guides/setup, guides/deploy, faq
```

## Signature

```ts title="@qino/cms"
tree.getFlatTree(): Promise<Array<TreeNode>>;
```

## Parameters

None.

## Returns

`Promise<Array<TreeNode>>` in pre-order. Each node still carries its own `children`.

## Throws

The same walk errors as [getTree](https://www.qino.works/docs/api/tree/get-tree).

## Example

```ts title="src/app/docs/[...slug]/page.tsx"
export async function generateStaticParams() {
  const nodes = await docsTree.getFlatTree();
  return nodes.map((node) => ({ slug: node.slug.split("/") }));
}
```
