File-based routing in NextJS - key feature of next js

Published: 31 March 2023
on channel: ReactJS tutorials
56
2

Learn more from: https://amzn.to/3FYGCOB

Now let’s talk about another key feature that next js has. That is file based routing. Now, what is file based routing?
Routing basically means that we give the user illusion of having multiple pages. So when user navigates and changes pages that is the job of the router. We change what is visible on the screen based on the url without sending extra request to a server.
Next js allows developers to create pages by simply creating files in a designated pages directory. For example, a file named "about.js" in the pages directory would create a route for "/about" in the application. This approach makes it easy to create new pages and handle dynamic routing. With this we are skipping the unnecessary writing of code that is needed when setting routing in react js applications. In the next js file structure we must have a folder pages, which must be named pages and there we structure the routes and paths of our page.

In plain ReactJS, we do not have a built-in routing system. Developers typically use third-party libraries such as React Router to handle routing. And the routing in react is set in code. This approach requires more setup and configuration.

According to this comparison we can conclude that with next js we have less code, less work and highly understandable concept.

Check my next tutorial to learn another key feature of Next JS.

Hit the like and subscribe button if you like my content.

Thanks for watching.


Watch video File-based routing in NextJS - key feature of next js online without registration, duration hours minute second in high quality. This video was added by user ReactJS tutorials 31 March 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 56 once and liked it 2 people.