How to Install shadcn/ui in React Vite with JavaScript Using create-shadcn-js
Are you looking for an easy way to install shadcn/ui in React Vite using JavaScript instead of TypeScript?
You're in the right place!
shadcn/ui is a popular collection of reusable, accessible, and beautifully designed React components.
However, many installation tutorials focus on TypeScript. What if you prefer plain JavaScript and JSX?
That's where create-shadcn-js comes in!
create-shadcn-js is an npm package designed for developers looking for a JavaScript-focused shadcn/ui setup.
You can explore the project and its source code here:
- NPM Package: https://www.npmjs.com/package/create-shadcn-js
- GitHub Repository: https://github.com/Skandan-V/create-shadcn-js
Why use create-shadcn-js?
Setting up a React application with shadcn/ui involves several configuration steps, including React, Vite, Tailwind CSS, import aliases, and component configuration.
A JavaScript-focused setup can make getting started easier for developers who prefer JSX instead of TSX.
Step 1: Explore the package
Before getting started, check out the package:
You can also explore the source code, README, and project updates on GitHub:
Step 2: Create your React project
Open your terminal and follow the installation command and project-generation instructions documented in the package README.
For a package exposing the conventional create-shadcn-js executable, the command is:
npx create-shadcn-js
Follow the prompts to configure your project. Choose JavaScript/JSX rather than TypeScript/TSX if that option is provided.
Step 3: Install dependencies
Navigate into the generated project directory:
cd your-project-name
Install dependencies if they have not already been installed:
npm install
Step 4: Start the development server
Run:
npm run dev
Open the localhost URL displayed in your terminal to view your React application.
Step 5: Start building with shadcn/ui
Once your project is configured, you can use shadcn/ui components to build modern interfaces.
For example, a Button component can look like this:
import { Button } from "@/components/ui/button";
function App() {
return (
<div className="flex min-h-screen items-center justify-center gap-4">
<Button>Primary Button</Button>
<Button variant="outline">
Outline Button
</Button>
<Button variant="destructive">
Delete Button
</Button>
</div>
);
}
export default App;
Make sure the Button component is available in your project before importing it.
Benefits of using JavaScript with shadcn/ui
- No requirement to use TypeScript in your application.
- Work with familiar JavaScript and JSX syntax.
- Build modern React interfaces.
- Customize component source code.
- Use Tailwind CSS for styling.
- Create reusable UI components.
Frequently Asked Questions
Can I use shadcn/ui with React Vite and JavaScript?
Yes. shadcn/ui supports JavaScript-based React projects when the configuration and generated components are set up for JSX.
Do I need TypeScript to use shadcn/ui?
No. You can use JavaScript instead of TypeScript in your React application.
What is create-shadcn-js?
create-shadcn-js is the npm package featured in this tutorial. It provides a JavaScript-oriented starting point for setting up a shadcn/ui project.
Where can I find the source code?
You can find the source code and project information on GitHub:
https://github.com/Skandan-V/create-shadcn-js
Conclusion
Building modern React applications with shadcn/ui doesn't mean you have to use TypeScript.
With a JavaScript-focused workflow, React, Vite, and shadcn/ui can work together to help you create clean, reusable, and customizable interfaces.
Give create-shadcn-js a try!
📦 NPM Package: https://www.npmjs.com/package/create-shadcn-js
💻 GitHub Repository: https://github.com/Skandan-V/create-shadcn-js
If you find the project useful, consider giving the GitHub repository a star ⭐ and sharing your feedback.
Happy coding! 🚀
Project Links
- NPM: https://www.npmjs.com/package/create-shadcn-js
- GitHub: https://github.com/Skandan-V/create-shadcn-js
- Official shadcn/ui: https://ui.shadcn.com/
Top comments (0)