Open In App

Blog app using ReactJS

Last Updated : 26 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Share
Report
News Follow

In this article, we have created the blog app using react js, First of all, we have created the project name blog by entering the command npx create-react-app blog and installing all modules. Then we create the folder name component under src and make two jsx file post.jsx and posts.jsx and styling the jsx component by post.css and posts.css. And last we import the component into App.js and styling the main into App.css.

Lets have a look at how the final application will look like.

Blog app using ReactJS

Blog app using ReactJS

Steps to create the application:

Step 1: Create React Project 

npx create-react-app blog

 Step 2: Change your directory and enter your main folder MY-APP as :

cd blog

Step 3: Install the required modules using the command

npm i bootstrap
npm i react-bootstrap

Step 4: Create a folder call components and create the files BlogNav.js, Posts.js, Post1.js, Post2.js, Post3.js, Post4.js

Project Structure: After following the above steps the project structure will look like

The dependencies in package.json will look like:

package.json

"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"bootstrap": "^5.3.0",
"react": "^18.2.0",
"react-bootstrap": "^2.7.4",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}

Example: Write the following code in your files

  • App.js: This file imports all the components and displays it
  • BlogNav.js: This file is used to create the navigation bar
  • Posts.js: This file renders the posts
  • Post1.js, Post2.js, Post3.js, Post4.js: These files contain the content of the blog
JavaScript
// App.js

import React from "react";
import "./App.css";

import Posts from "./components/Posts";
import Navbar from "./components/BlogNav"

const App = () => {
    return (
        <div className="main-container" style={{backgroundColor: "aliceblue"}}>
            <Navbar />
            <Posts />
        </div>
    );
};

export default App;
JavaScript JavaScript JavaScript JavaScript JavaScript JavaScript

Step to run the application:  Open the terminal and run the project using the command.

npm start

Output: Your project is shown in the URL http://localhost:3000/



Next Article

Similar Reads

three90RightbarBannerImg