---
name: "getCurrentPages"
mode: "kit"
versionRequirements:
  - { name: "@ray-js/ray", version: "0.2.0" }
---

## getCurrentPages

> [VERSION] @ray-js/ray >= 0.2.0

> 💡 1. Do not attempt to modify the page stack; it will cause routing and page state errors.
> 2. Do not call getCurrentPages() during App.onLaunch; pages have not been created yet.

### Description

Get the current page stack. Returns an array of page objects; the first element is the home page and the last element is the current page.

### Parameters

None


### Examples

#### Basic usage

```tsx
import React from 'react';
import { View, Button, getCurrentPages } from '@ray-js/ray';

export default function Home() {
  const handleGetPages = () => {
    const pages = getCurrentPages();
    console.log('Current page stack length:', pages.length);
    console.log('Current page:', pages[pages.length - 1]);

    pages.forEach((page, index) => {
      console.log(`Page ${index}:`, page.route);
    });
  };

  return (
    <View style={{ padding: 20 }}>
      <Button onClick={handleGetPages}>Get page stack</Button>
    </View>
  );
}
```
