Skip to main content

A step-by-step guide to set up a React (TypeScript) project with Tailwind CSS, ShadCN, and TanStack Router using Vite.

🚀 1️⃣ Create a New Vite + React (TypeScript) Project

Run the following command to create a new project:

npm create vite@latest my-app --template react-ts

Then, navigate into the project folder:

cd my-app


🎨 2️⃣ Install Tailwind CSS

Install Tailwind and its dependencies:

npm install -D tailwindcss postcss autoprefixer

Generate the Tailwind configuration files:

npm list tailwindcss
echo "module.exports = { content: ['./index.html', './src/**/*.{js,ts,jsx,tsx}'], 
theme: { extend: {}, }, plugins: [], };" > tailwind.config.js
echo "module.exports = { plugins: { tailwindcss: {}, autoprefixer: {}, }, };" > 
postcss.config.js

Finally, import Tailwind into your styles:

  • Open src/index.css and replace the contents with:
@tailwind base;
@tailwind components;
@tailwind utilities;

🎭 3️⃣ Install ShadCN/UI

ShadCN provides pre-built UI components.

First, install ShadCN:

npm install -g shadcn-ui

Initialize it:

npx shadcn@latest init

Replace the content of tsconfig.json with:


{
  "compilerOptions": {
    "baseUrl": ".",
    "paths": {
      "@/*": ["src/*"]
    }
  },
  "files": [],
  "references": [
    { "path": "./tsconfig.app.json" },
    { "path": "./tsconfig.node.json" }
  ]
}



When prompted:

  • TypeScript: Yes
  • Tailwind CSS: Yes
  • Alias (@/components/ui): Press Enter (default)
  • Confirm installation: Yes

Now, install the UI components you need (e.g., button, input):

npx shadcn@latest add button input

🚏 4️⃣ Install TanStack Router

TanStack Router is a powerful alternative to React Router.

npm install @tanstack/react-router
npm install -D @tanstack/router-plugin @tanstack/router-devtools

Set up a router file src/lib/router.tsx:

import { createRouter, RouterProvider } from "@tanstack/react-router";
import { Route, RootRoute } from "@tanstack/react-router";
import HomePage from "@/pages/HomePage";

const rootRoute = new RootRoute();
const homeRoute = new Route({
  getParentRoute: () => rootRoute,
  path: "/",
  component: HomePage,
});

const routeTree = rootRoute.addChildren([homeRoute]);

const router = createRouter({
  routeTree,
  notFoundComponent: () => <h1>404 Not Found</h1>,
});

export { router, RouterProvider };

Now, wrap your app in main.tsx:

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App.tsx";
import { RouterProvider, router } from "@/lib/router";

ReactDOM.createRoot(document.getElementById("root")!).render(
  <React.StrictMode>
    <RouterProvider router={router} />
  </React.StrictMode>
);

✅ 5️⃣ Start the Development Server

Run:

npm run dev

Visit http://localhost:5173/, and you have: ✔ React + TypeScript
✔ Tailwind CSS
✔ ShadCN UI
✔ TanStack Router

🔥 Now, you're ready to build! 🚀 

Comments

Popular posts from this blog

Depression is a bridge off the root of rejection

The statement "Depression is a bridge off the root of rejection" suggests that depression can often stem from a deeper sense of rejection and emotional hurt and that this rejection acts as the foundational root for depressive episodes. To expound on this, it’s helpful to break down the metaphor and understand how rejection can play a significant role in triggering depression : 1. Rejection as a Root What is Rejection? Rejection refers to the act of being dismissed, excluded, or not accepted by others. It could come in many forms, such as: Relational rejection : From family, friends, or romantic partners. Social rejection : From peers, groups, or communities. Professional rejection : Failing to meet job expectations or being denied opportunities. Self-rejection : Internalizing negative feelings and self-worth, rejecting one's own value. How Rejection Can Affect Mental Health Rejection is a deep emotional wound because humans are inherently social beings who desire acce...

Understanding how different emotional roots lead to certain outcomes or experiences

In the context of emotional, psychological, and spiritual growth, the concept of a bridge can be a powerful metaphor for understanding how different emotional roots lead to certain outcomes or experiences. Beyond the bridge from rejection to depression, there are several other significant bridges in our emotional and spiritual lives: 1. Bridge from Trauma to Fear Trauma is often the root of fear. People who have experienced significant trauma, whether it be physical, emotional, or psychological, frequently develop fears as a protective mechanism. Fear can manifest in many forms—fear of vulnerability, fear of trust, or fear of loss. For example, someone who experienced abandonment in childhood might develop a fear of intimacy, leading to avoidance of close relationships as an adult. Key Effects : Anxiety, hypervigilance, and avoidance behaviors often stem from trauma, crossing the bridge into fear-based responses to life. 2. Bridge from Shame to Isolation Shame is a deep-rooted feel...

Who I Am in the Lord: Daily Confession

Here are some powerful confessions that reflect your identity in the Lord, based on biblical truths: Who I Am in the Lord I am a Child of God "I am a child of God, adopted into His family, and I belong to Him." (John 1:12) I am Forgiven "I am forgiven of all my sins; my past does not define me." (Ephesians 1:7) I am Redeemed "I am redeemed by the blood of Jesus, set free from the bondage of sin." (Galatians 3:13) I am a New Creation "I am a new creation in Christ; the old has passed away." (2 Corinthians 5:17) I am Loved "I am deeply loved by God, no matter my circumstances." (Romans 5:8) I am Chosen "I am chosen by God, set apart for His purposes." (1 Peter 2:9) I am Heir to His Promises "I am an heir to the promises of God; all His blessings are mine." (Romans 8:17) I am Strong in the Lord "I am strong in the Lord and in His mighty power." (Ephesians 6:10) I am Healed ...