Company
Date Published
Author
Victory Tuduo
Word count
3473
Language
English
Hacker News points
None

Summary

Strapi is an open-source headless CMS built on Node.js, enabling developers to create and manage the contents of their applications. It provides users with an admin panel to manage user's content and allows collaborative access to content to enable multiple users to access and manage stored data. To set up our Strapi back-end, we created a directory for our project, installed Strapi using npm, and configured it with a sqlite database. We then created a Collection type in Strapi to contain the post and comments for our forum application. Next, we built the front-end of our forum application with Next.js, setting up two pages: one to display the forum and another to post new questions. We fetched data from Strapi using Axios and passed it to the Displayforum component to display it in the browser. To enable user authentication and authorization on our app, we used Nextauth, a NextJs package for authentication, to implement Google login. We also set up protected routes so that only authenticated users can create questions and view them. Finally, we added functionality to add new answers to Strapi's JSON field of type Answers, displaying the username received from session in the answer.