What is Page Routing?
WordPress is built on the widely used server-side language PHP, which is a great language for creating static webpages. Page routing within PHP, in its basic form, is simply typing in the path to the file within the URL address. So for example, if you are at a domain
https://example.com and you want to route to the blog you can simply add
/blog to the address so that you would go to the URL
https://example.com/blog. This is very easy for both the user and the developer, but with PHP there needs to be a page refresh to get the new content. This is not horrible for some static sites, but for other real-time sites it can be very cumbersome.
Routing in Node.js with Page.js
The Actual Code
Now I will attempt to explain how Calypso page routing really happens and if I am wrong in at all please let me within he comments below 🙂
/client folder within Calypso is where most of the magic happens and it where Page.js is initially triggered to start the routing engine. As you can see by the description within Github the
If you follow the fantastic Hello World tutorial you will see that you can register new pages with Calypso by adding in a new endpoint within the
/client/sections.js file. After completing the tutorial you should have a better understand of how Page.js works and how Calypso uses it.