You can start the application by running the npm start command.
If you open the app at http://localhost:3000 in your browser (Chrome, for example) and you right-click and then View page source, you will probably notice that we are not using SSR:
This is because we will only use SSR for search bots. The isBot function will detect all the search bots, and just for a test I added curl as a bot to test our SSR; this is the code of that function:
export function isBot(ua) {
const b = /curl|bot|googlebot|google|baidu|bing|msn|duckduckgo|teoma|slurp|yandex|crawler|spider|robot|crawling/i;
return b.test(ua);
}
Open a new terminal while you have the application running in another terminal, and then execute the following command:
curl http://localhost:3000
As you can see, the HTML code inside the #root div is render it using the SSR.
Also, if you want to try to run /about in curl, you will see that also will render it using SSR:
There is an extension for Chrome called User-Agent Switcher for Chrome where you can specify the user agent you want to use in your browser. In this way, you can add a special user agent for Googlebot, for example:
Then, if you select Chrome | Bot in User-Agent Switcher, you can see that the HTML code renders it as SSR when you do View page source: