---
url: /filament-relation-navigator/guide/previous-and-next-record.md
---
# Previous and next record

Two buttons before the header actions open the previous or the next record
**on the same page**: from a customer's invoices to the next customer's
invoices.

A record that cannot open that page opens on its first
page in the menu. They are off by default, since they add a few queries per
render:

```php
'record_navigation' => true,
```

They follow **the list the user came from**: its sort, filters, search and
tab, as on screen (up to 100 records; about 30 with UUID keys). From the first or the last record of
that list there is nothing further, rather than a jump to another order. A
record that is not in the list (opened from a link) walks by key. To always
walk by key:

```php
'record_navigation_follows_list' => false,
```

The list remembers its records only when record navigation is on in the
config or on the resource (`hasRelationNavigatorRecordNavigation()`), since
the list page cannot ask a record page.

They walk through the resource's own query (`getRecordRouteBindingEloquentQuery()`),
so tenancy and your scopes apply, and skip the records the user cannot view.
Per page:

```php
public function hasRelationNavigatorRecordNavigation(): bool
{
    return true;
}

public function getRelationNavigatorRecordNavigationQuery(): ?Builder
{
    return Customer::query()->where('active', true);
}
```

On a **nested resource** they stay within the parent: from one of a
customer's orders to the next order of the same customer. The list there is
the parent's relation manager: they follow its order when the nested resource
is its related resource (`protected static ?string $relatedResource`), except
with the `cookie` session driver, which keeps the parent's list only.
