create-swc-vite-react-app

March 30, 2025 ยท View on GitHub

A CLI tool to create React applications with Vite and Spectrum Web Components for fast development and build times. Now with MCP support for integration with AI assistants!

Features

  • โšก๏ธ Lightning fast development with Vite
  • ๐Ÿ“ฆ TypeScript support built-in
  • โš›๏ธ React 19+ for the latest features
  • ๐ŸŽจ Spectrum Web Components integration
  • ๐ŸŒˆ Customizable theming options
  • ๐Ÿ” ESLint configuration included
  • ๐Ÿงฉ Path aliases (@components) for clean imports
  • ๐ŸŽจ Beautiful default template
  • ๐Ÿ“ฑ Responsive design ready
  • ๐ŸŒ™ Dark mode support
  • ๐Ÿค– MCP support for integration with AI assistants

Generated App Preview

The generated app comes with a beautiful, responsive layout that includes a header, sidebar navigation, and main content area. Here's how it looks:

Generated App Preview

The app includes (some of the items listed below are still in development):

  • Modern, clean design
  • Responsive layout
  • Dark/Light theme support
  • Customizable color schemes
  • Collapsible sidebar
  • Ready-to-use Spectrum components

Quick Start

# Using npm
npx create-swc-vite-react-app my-app

# Using yarn
yarn create swc-vite-react-app my-app

# Using pnpm
pnpm create swc-vite-react-app my-app

# Create project in current directory
npx create-swc-vite-react-app .

Options

  • --eslint - Include ESLint configuration (default: true)
  • --use-npm - Use npm as package manager
  • --use-pnpm - Use pnpm as package manager
  • --use-yarn - Use yarn as package manager
  • --theme-scale - Theme scale: large, medium, or both (default: both)
  • --theme-color - Theme color: dark, light, or both (default: both)
  • --system - Design system: spectrum, spectrum-two, or express (default: spectrum)
  • --mcp - Start in MCP mode for integration with AI assistants

Note: The SpTheme.ts file will be customized with the appropriate imports based on your theme selections.

Project Structure

The generated project will have the following structure:

my-app/
โ”œโ”€โ”€ node_modules/
โ”œโ”€โ”€ public/
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ components/
โ”‚   โ”‚   โ”œโ”€โ”€ icons/
โ”‚   โ”‚   โ”‚   โ””โ”€โ”€ [icon components]
โ”‚   โ”‚   โ”œโ”€โ”€ Accordion.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ActionBar.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ActionButton.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ActionGroup.ts
โ”‚   โ”‚   โ”œโ”€โ”€ ActionMenu.ts
โ”‚   โ”‚   โ”œโ”€โ”€ AlertBanner.ts
โ”‚   โ”‚   โ”œโ”€โ”€ AlertDialog.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Button.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Card.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Checkbox.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Dialog.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Icon.ts
โ”‚   โ”‚   โ”œโ”€โ”€ SpTheme.ts (imports customized based on theme options)
โ”‚   โ”‚   โ”œโ”€โ”€ Toast.ts
โ”‚   โ”‚   โ”œโ”€โ”€ Tooltip.ts
โ”‚   โ”‚   โ”œโ”€โ”€ types.ts
โ”‚   โ”‚   โ””โ”€โ”€ [60+ components in total]
โ”‚   โ”œโ”€โ”€ layout/
โ”‚   โ”‚   โ”œโ”€โ”€ Header.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Header.css
โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar.tsx
โ”‚   โ”‚   โ”œโ”€โ”€ Sidebar.css
โ”‚   โ”‚   โ”œโ”€โ”€ MainContent.tsx
โ”‚   โ”‚   โ””โ”€โ”€ MainContent.css
โ”‚   โ”œโ”€โ”€ App.tsx
โ”‚   โ”œโ”€โ”€ App.css
โ”‚   โ””โ”€โ”€ main.tsx
โ”œโ”€โ”€ .eslintrc.cjs
โ”œโ”€โ”€ index.html
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ tsconfig.json
โ”œโ”€โ”€ tsconfig.node.json
โ””โ”€โ”€ vite.config.ts

The project includes:

  • components/: A comprehensive set of Spectrum Web Components wrappers
    • icons/: SVG icon components
    • Various UI components (60+ components available)
    • SpTheme.ts: Theme configuration (customized based on your options)
    • types.ts: TypeScript type definitions
  • layout/: Pre-built layout components
    • Header: Application header with navigation
    • Sidebar: Collapsible side navigation
    • MainContent: Main content area with responsive design
  • App.tsx: Main application component
  • Configuration files: ESLint, TypeScript, and Vite configs

Available Scripts

In the project directory, you can run:

  • npm dev - Starts the development server
  • npm build - Bundles the app for production
  • npm preview - Preview the production build locally
  • npm lint - Run ESLint to check code quality

MCP Support

This tool now includes MCP (Model Context Protocol) mode support.

MCP Features

  • Tools: The MCP server exposes a create-app tool that can create a new project with the same options as the CLI.
  • Prompts: The MCP server includes a prompt for guiding users through creating a new project.
  • Resources: Documentation for CLI options is available as a resource.

Integration with Cursor

To integrate with Cursor, you can configure it to use this tool with the MCP protocol. This allows Cursor's AI assistant to directly create SWC+Vite React applications based on user instructions.

{
  "mcpServers": {
    "create-swc-vite-react-app": {
      "command": "npx",
      "args": ["-y", "create-swc-vite-react-app@latest", "--mcp"],
      "env": {}
    }
  }
}

Requirements

  • Node.js 18.0.0 or later
  • npm 7.0.0 or later, yarn 1.22.0 or later, or pnpm 7.0.0 or later

Dependencies

Key dependencies:

  • @modelcontextprotocol/sdk: ^1.8.0
  • chalk: ^5.4.1
  • commander: ^13.1.0
  • fs-extra: ^11.3.0
  • prompts: ^2.4.2
  • validate-npm-package-name: ^6.0.0

License

MIT