Building a SPA
While you can build complete web applications with Gin by rendering HTML templates and serving the static files, as the application grows it becomes hard to maintain it. That's why you can adopt a popular frontend JavaScript framework such as Angular, React, or Vue.js to build your SPA. In this section we will go with React, but you can get the same results with other JavaScript frameworks as well.
The application we'll build will do the following:
- Display the list of all recipes on the home page (for all users).
- Let users sign in with their username and password.
- Let users create new recipes (logged-in users only).
First of all, we will need to make sure that Node.js is installed on your system. You can install the long-term support (LTS) version (14.16.0) from the official page at https://nodejs.org/en/download/, or you can use the Node Version Manager (NVM) to install Node.js easily, based on your operating system (OS).
To install...