- This App will be a blog where users can add a blog with a title, blog text, and a user name.
- It will have auth credentials, loggin with google account as well as button to delete a blog if they wish.
- We will use hooks as well as components; props will be also used.
- We will use Firebase app and host to deploy the app.
- So they app will have a login page, home, and a Create Post page.
- Firebase
- Firebase functions
- Express.js
- cors
- Create project using you terminal npx create-react-app blog-website
- So go to setting and create it.
Go to Visual Code or terminal and install firebase dependencies or packages. -npm i firebase or yarn add firebase if you are using it.
- If already have an account in firebase, go to console, configure, and create a project. We use Firebae database
- Create component firebase-Config in visual to connect the app with the app in firebase console.
- Go to authentication in Firebase and click in 'get Started'.
- Click google althougt there are other options
- Then Enable, use an email, and save.
- Click on enable; then click on create database and set it up in production mode.
- Click enable and it will start a collection or database.
- We create a collection in Firebase and modify rules to unable user to add content.
- Now we create a set up aunthentification in firebase-config compponent in our visual code.
- Create conections (export,import) accordingly to implement them in the project.
In order to create routes whithin pages we need to install react-router-dom and import it, and after that, we need to set up our routes fro Home, Login, and CreatePost.
- Copy this in terminal: npm install react-router-dom
Create links to be able to navigate through pages
Create funtionality, and stablish a function so that the login link does not appear in 'is loggin'.
Create functionality so that the user can have the 'logout' link if the are logged in.
css is implemented to the login page and stylish.
- This page is create in a way that the users can add content if they are login. To do that, we use useState and useEffect, and create fucntion link to the click buttons. Props are also utilized is this process.
- Then we create our first post and submit it.
- We need to access the post that sit in our database. The useState is used, so we import it and initilize it with an empty array.
- To populate the homePage we need to use (useEffect) and get the data we need and display it.
- CSS is added at this stage.
Add a function to delete post when the users want, using async await.
In the project directory, run: