Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Renaming page.tsx files in Nextjs 13 app directory

I want to be able to rename page.tsx files in nextjs 13 app directory to something like theRouteName.page.tsx or something like this. because if all the pages are named page.tsx it's gonna be a pain to work on multiple pages in the IDE, I know we can write some kind of plugin for VS code etc. but that is not the option for me. any ideas?

like image 677
Hamed Tahmasebi Avatar asked Jan 28 '26 06:01

Hamed Tahmasebi


2 Answers

I agree with OP, even with a simple app it cam become confusing: enter image description here

Let alone what will happen with an enterprise app. What I've done is created a default export in the page.tsx, for example:

page.tsx:

import Homepage from './home.page'
export default Homepage

It's still not perfect, but better than it was before

enter image description here

You could also do the same for layouts, error, etc...

like image 62
BleddP Avatar answered Jan 30 '26 18:01

BleddP


I recommend checking out the official Next.js 13 documentation on pageExtensions to personalize page file names

https://nextjs.org/docs/pages/api-reference/next-config-js/pageExtensions

By exploring this section of the documentation, you'll find a practical examples on how to configure page name extensions to align with your preferences

like image 29
lincon-fernandes Avatar answered Jan 30 '26 19:01

lincon-fernandes



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!