DEV Community

Cover image for Build React Apps with shadcn/ui Without TypeScript Using create-shadcn-js
Skandan V
Skandan V

Posted on

Build React Apps with shadcn/ui Without TypeScript Using create-shadcn-js

Want to use shadcn/ui in your React project without TypeScript?

Many React developers love shadcn/ui because of its beautiful components, customizable styles, and developer-friendly approach.

But there is one common problem: most tutorials and examples use TypeScript.

If you're comfortable with JavaScript and JSX, switching to TypeScript just to use a UI component library might feel unnecessary.

Fortunately, you can build modern React applications with shadcn/ui using JavaScript!

In this article, we'll look at how to get started with a JavaScript-based shadcn/ui workflow using create-shadcn-js.

What is shadcn/ui?

shadcn/ui is a collection of reusable React components that you can customize directly inside your application.

Unlike traditional component libraries, shadcn/ui provides component source code that becomes part of your project.

This gives you more flexibility to customize components according to your application's requirements.

Some popular components include:

  • Button
  • Card
  • Input
  • Dialog
  • Dropdown Menu
  • Select
  • Tabs
  • Accordion
  • Table
  • Sheet

You can explore all available components here:

https://ui.shadcn.com/docs/components

Can you use shadcn/ui without TypeScript?

Absolutely!

You don't need TypeScript to build applications with shadcn/ui.

React supports both JavaScript and TypeScript, and shadcn/ui can be configured to generate JavaScript components using JSX.

For developers who prefer JavaScript, this means you can work with:

  • .js files instead of .ts
  • .jsx files instead of .tsx
  • JavaScript functions and objects
  • Regular React components
  • Tailwind CSS utility classes

You can enjoy the benefits of shadcn/ui without making TypeScript a requirement for your application.

Introducing create-shadcn-js

If you're looking for a JavaScript-focused way to get started with shadcn/ui, check out create-shadcn-js.

It's the npm package featured in this tutorial.

You can find the package here:

šŸ“¦ NPM: https://www.npmjs.com/package/create-shadcn-js

šŸ’» GitHub: https://github.com/Skandan-V/create-shadcn-js

The project is intended for developers who want a JavaScript-oriented shadcn/ui setup.

Instead of starting from scratch, explore the package's documented setup workflow and use it as your starting point.

Getting started with create-shadcn-js

Step 1: Check the npm package

First, visit the npm package page:

https://www.npmjs.com/package/create-shadcn-js

You can find the latest installation instructions and package information there.

Step 2: Create your project

Open your terminal and follow the package README.

If using the conventional executable invocation, run:

npx create-shadcn-js
Enter fullscreen mode Exit fullscreen mode

Follow the available prompts to configure your project.

Choose JavaScript/JSX if the setup provides a language selection.

Step 3: Install dependencies

Navigate into your newly created project:

cd your-project-name
Enter fullscreen mode Exit fullscreen mode

Install the dependencies if they haven't already been installed:

npm install
Enter fullscreen mode Exit fullscreen mode

Step 4: Run your React application

Start the Vite development server:

npm run dev
Enter fullscreen mode Exit fullscreen mode

Open the localhost URL displayed in your terminal.

Your React application should now be running.

Build beautiful interfaces with shadcn/ui

Once your project is configured, you can start building reusable UI components.

For example, let's look at a simple React component using a shadcn Button.

import { Button } from "@/components/ui/button";

function App() {
  return (
    <main className="flex min-h-screen items-center justify-center bg-background">
      <div className="space-y-4 text-center">
        <h1 className="text-3xl font-bold">
          Welcome to My App
        </h1>

        <p className="text-muted-foreground">
          Built with React, JavaScript and shadcn/ui.
        </p>

        <div className="flex justify-center gap-3">
          <Button>Get Started</Button>

          <Button variant="outline">
            Learn More
          </Button>
        </div>
      </div>
    </main>
  );
}

export default App;
Enter fullscreen mode Exit fullscreen mode

This example demonstrates how you can build a clean interface using JSX and Tailwind CSS.

Make sure the Button component is installed and the @ alias is configured in your project.

JavaScript vs TypeScript for shadcn/ui

Both options are useful for React development.

Here's a quick comparison:

Feature JavaScript TypeScript
File extension .js, .jsx .ts, .tsx
Type checking No built-in static type checking Yes
Learning curve Easier for JavaScript beginners Requires learning TypeScript
React support Yes Yes
shadcn/ui support Yes, with JS configuration Yes
Customization Yes Yes

Choose the language that best fits your project and development workflow.

Why developers choose shadcn/ui

1. Complete customization

You get component source code directly in your project, making it easier to customize the appearance and behavior.

2. Modern design

shadcn/ui provides a collection of modern components suitable for dashboards, SaaS applications, admin panels, and other React projects.

3. Reusable components

Build reusable UI elements and maintain a consistent design throughout your application.

4. Tailwind CSS integration

Use Tailwind CSS utility classes to customize spacing, colors, layouts, typography, and responsive designs.

5. Accessibility

shadcn/ui components are designed with accessibility in mind.

Frequently Asked Questions

1. Is shadcn/ui compatible with JavaScript?

Yes. You can configure shadcn/ui to generate JavaScript and JSX components instead of TypeScript and TSX.

2. Can I use shadcn/ui with Vite?

Yes. shadcn/ui supports React applications created with Vite.

3. What is create-shadcn-js?

create-shadcn-js is an npm package focused on a JavaScript-oriented shadcn/ui setup.

NPM: https://www.npmjs.com/package/create-shadcn-js

4. Is shadcn/ui better than traditional component libraries?

It depends on your requirements. shadcn/ui is particularly useful when you want direct access to component source code and greater customization.

5. Can beginners use shadcn/ui?

Yes. Developers with basic knowledge of React, JavaScript, and CSS can start using shadcn/ui.

Final Thoughts

You don't have to use TypeScript to build beautiful React applications with shadcn/ui.

JavaScript, JSX, React, Vite, and Tailwind CSS provide everything you need to create modern and reusable interfaces.

If you prefer JavaScript and want to explore a JavaScript-focused shadcn/ui setup, check out create-shadcn-js.

šŸ“¦ Try the npm package:

https://www.npmjs.com/package/create-shadcn-js

⭐ Explore the GitHub repository:

https://github.com/Skandan-V/create-shadcn-js

If you find the project useful, consider giving the repository a star and sharing your feedback.

Happy building! šŸš€


Useful Resources

Top comments (0)