Setting up a React + Vite project for building your personal portfolio is a great choice because it provides a fast development environment with modern features. Here's a step-by-step guide to help you set up your React + Vite project and start building your personal portfolio:
Step 1: Create a New Vite Project with React Template
-
Open your terminal (command prompt or terminal in VSCode) and run the following command to create a new Vite project with React template:
npm create vite@latest my-portfolio --template react
This will create a new folder called
my-portfolio
with all the necessary files for a React project using Vite. -
After the project is created, navigate to the project directory:
cd my-portfolio
-
Install the dependencies:
npm install
Step 2: Set Up Tailwind CSS (Optional)
If you want to use Tailwind CSS for styling your portfolio (which is highly recommended for quick, responsive, and clean design), follow these steps:
-
Install the required packages for Tailwind CSS:
npm install -D tailwindcss postcss autoprefixer
-
Initialize Tailwind CSS configuration:
npx tailwindcss init
This will create a
tailwind.config.js
file. -
Open
tailwind.config.js
and set up the content path:/** @type {import('tailwindcss').Config} */ module.exports = { content: [ "./index.html", "./src/**/*.{js,jsx,ts,tsx}" ], theme: { extend: {}, }, plugins: [], }
-
Create a new CSS file (e.g.,
src/styles/index.css
), and add the following Tailwind directives:/* src/styles/index.css */ @tailwind base; @tailwind components; @tailwind utilities;
-
Import this CSS file into your
src/main.jsx
:import './styles/index.css';
Step 3: Start the Development Server
Now that everything is set up, you can run the development server and see your portfolio project in action:
npm run dev
Open your browser and go to http://localhost:3000
to see the default React page.
Step 4: Build the Structure of Your Portfolio
Now, let's start building the actual structure of your personal portfolio. Here’s a typical structure for a personal portfolio:
- Home Section: An introduction to who you are (your name, profession, skills).
- About Section: More details about your journey, education, and goals.
- Projects Section: A showcase of your projects (with descriptions and links).
- Contact Section: Information for contacting you (like email or a contact form).
- Footer Section: Links to your social media or other important links.
You can divide these sections into different components for a clean and modular structure.
Step 5: Create Portfolio Components
Inside the src
folder, create the following components:
Home.jsx
— Introduction sectionAbout.jsx
— About sectionProjects.jsx
— Projects showcaseContact.jsx
— Contact form or contact informationFooter.jsx
— Footer with social media links
For example, in src/components/Home.jsx
:
function Home() {
return (
<section className="h-screen flex items-center justify-center bg-blue-500 text-white">
<div className="text-center">
<h1 className="text-4xl font-bold">Hello, I'm Shashankar Ki</h1>
<p className="mt-4 text-xl">A passionate web developer</p>
</div>
</section>
);
}
export default Home;
Repeat similar steps for the other sections like About, Projects, Contact, etc.
Step 6: Layout the Components in App.jsx
In your src/App.jsx
, import the components and arrange them in order:
import Home from './components/Home';
import About from './components/About';
import Projects from './components/Projects';
import Contact from './components/Contact';
import Footer from './components/Footer';
function App() {
return (
<div>
<Home />
<About />
<Projects />
<Contact />
<Footer />
</div>
);
}
export default App;
Step 7: Add Basic Styling and Tailwind Classes
Use Tailwind CSS classes to style your components. For example, in the Home.jsx
component, I used h-screen
, flex
, items-center
, justify-center
, and other utility classes to center the content vertically and horizontally.
You can also create custom CSS classes in src/styles/index.css
for global styles.
Step 8: Add Navigation (Optional)
If you want to add navigation to jump to different sections of your portfolio, you can use React Router.
-
Install
react-router-dom
:npm install react-router-dom
-
Set up routes and links in your
App.jsx
file:
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import Home from './components/Home';
import About from './components/About';
import Projects from './components/Projects';
import Contact from './components/Contact';
import Footer from './components/Footer';
function App() {
return (
<Router>
<div>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#projects">Projects</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
<Routes>
<Route path="/" element={<Home />} />
<Route path="/about" element={<About />} />
<Route path="/projects" element={<Projects />} />
<Route path="/contact" element={<Contact />} />
</Routes>
<Footer />
</div>
</Router>
);
}
export default App;
Step 9: Deploy the Portfolio
Once you're done with your portfolio, you can deploy it to platforms like Netlify, Vercel, or GitHub Pages.
For example, to deploy with Netlify:
- Push your code to GitHub (if you haven’t already).
- Go to Netlify and create a new site from GitHub.
- Follow the steps to deploy, and your portfolio will be live!
Conclusion:
By following these steps, you can easily create a React + Vite personal portfolio website with Tailwind CSS (optional) for styling. You'll learn React, Vite, and Tailwind in the process, and you can showcase your skills with a beautiful, modern portfolio.
Let me know if you need help with any specific part of the setup!
No comments:
Post a Comment