Skip to content

feat(paginator): add custom page name - #1162

Merged
thetutlage merged 3 commits into
adonisjs:22.xfrom
FlorianV85:feat/paginator-page-name
May 7, 2026
Merged

feat(paginator): add custom page name#1162
thetutlage merged 3 commits into
adonisjs:22.xfrom
FlorianV85:feat/paginator-page-name

Conversation

@FlorianV85

@FlorianV85 FlorianV85 commented Mar 22, 2026

Copy link
Copy Markdown
Contributor

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

The purpose of this PR is to add the option to customize the page name (Paginator). Currently, metadata generates URLs with a static page query parameter.

Why would this be useful?

  • Generally, it is preferable to give developers the freedom to adapt whatever they need. For example: in a special context, you might need a qs named something other than page. Imagine that you have multiple paginations on the same page.
  • This can simplify the implementation of certain features in some packages, such as Inertia Adapter.

Implementation is very simple:
The custom page name can be defined with a new pageName argument added to the Paginator:

const users = await User.query().paginate(1, 5, 'customPageName')

Now all metadata has the correct URLs with the custom page name.
users?customPageName=x

If no page name is defined, pageName defaults to page.

A test has been added, and it appears to be successful.

📝 Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@thetutlage

Copy link
Copy Markdown
Member

Hello @FlorianV85

Thanks for the PR. Can you please open another PR for the docs as well? https://github.com/adonisjs/lucid.adonisjs.com/tree/main

@FlorianV85

Copy link
Copy Markdown
Contributor Author

It's done! adonisjs/lucid.adonisjs.com#63

@thetutlage
thetutlage merged commit 91efd76 into adonisjs:22.x May 7, 2026
9 checks passed
@thetutlage

Copy link
Copy Markdown
Member

Thanks 👍🏽

I may rename the .paginate prop to be an object and not a bare string before the release

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants