Welcome to the Lit Starter Kit. This is not an official kit for the Lit library, but this is a tool to get a component library up and running quickly.
Before getting started, make sure you have the following installed:
This repository is designed to be a "batteries included" repo, so you can hit the ground running with what you need to start delivering components. This repo includes:
/cdn)/dist)/react)/types)/types)/types)/wc.config.js)You can choose to fork this repository directly or you can run the following command to create a new project.
npm init lit-starter-kit your-project-name
Once created, navigate to your project directory and install dependencies:
cd your-project-name
Understanding the project structure will help you navigate and customize the library:
├── src/ # Source code for your components
│ ├── index.ts # Main entry point
│ └── components/ # Component definitions
├── dist/ # NPM package build output (generated)
├── cdn/ # CDN build output (generated)
├── react/ # React wrapper components (generated)
├── types/ # Framework type definitions (JSX, Vue, Svelte)
├── plop-templates/ # Component generator templates
├── public/ # Build outputs for CDN, HTML, and React
└── .storybook/ # Storybook configuration
The development environment uses Storybook to showcase and document the components. The documentation files are written in MDX files to increase portability in case you wan to use a different tool for documenting your components.
npm run dev
This command will: - Build your components - Watch for changes and rebuild automatically - Start Storybook on http://localhost:6006
This project leverages plop to generate new components in your library. You can create a new component by running the following command and following the prompts.
npm run new
This will scaffold: - Component TypeScript file - Styles file - Test file - Storybook stories - MDX documentation
Maintain code quality with built-in linting and formatting tools:
# Run all linters
npm run lint
# Run ESLint
npm run lint:eslint
# Run Prettier check
npm run lint:prettier
# Auto-fix issues
npm run format
Generating the final build assets will generate the dist assets for the NPM package, the content for the CDN located in the cdn directory at the root of the project, as well as the meta content for your components like framework integrations like types and react wrappers.
npm run build
This generates:
- /dist - NPM package distribution files
- /cdn - CDN-ready bundles for direct browser usage
- /react - React wrapper components
- /types - TypeScript definitions and framework integrations
- custom-elements.json - Component metadata manifest
# Build only CDN version
npm run build:cdn
# Build only React wrappers
npm run build:react
# Build static Storybook documentation
npm run build-storybook
Tests are written and executed using web-test-runner which execute your tests in real browsers to validate your APIs are working as expected in the environments you intend to be using them in.
Tests can be configured in the web-test-runner.config.js file located at the root of the project.
Tests can be run using the following command:
npm test
Once built, your components can be used in multiple ways:
npm install your-package-name
// Import all components
import 'your-package-name';
// Or import specific components
import 'your-package-name/components/button';
// Use in your HTML
<my-button variant="primary">Click Me</my-button>
<script type="module">
import 'https://cdn.example.com/your-package/index.js';
</script>
<my-button>Click Me</my-button>
import { MyButton } from 'your-package-name/react';
function App() {
return <MyButton variant="primary">Click Me</MyButton>;
}
TypeScript and JSX support is included via the /types directory. Type definitions are automatically recognized by TypeScript when you import the components.
Framework-specific type integrations are provided in the /types directory for Vue.js and Svelte to ensure proper type checking and intellisense.
Before publishing, update your package details:
Update package.json:
json
{
"name": "@your-scope/your-package-name",
"version": "1.0.0",
"description": "Your component library description",
"author": "Your Name",
"repository": {
"type": "git",
"url": "https://github.com/your-username/your-repo"
}
}
Build and publish:
bash
npm run build
npm publish
Or use the deploy script:
bash
npm run deploy
bash
npm publish --access publicname field in package.jsonComponents use Lit's styling system. Create shared styles in a common file and import them into your components:
import { css } from 'lit';
export const sharedStyles = css`
:host {
/* Your shared styles */
}
`;
To deploy your Storybook documentation:
npm run build-storybook
This creates a static site in storybook-static/ that can be deployed to:
- GitHub Pages
- Netlify
- Vercel
- Any static hosting service
pnpm install.js for TypeScript files)npx playwright install to install test browsersContributions are welcome! This project uses: - Husky for git hooks - lint-staged for pre-commit linting - Prettier for code formatting - ESLint for code quality
Code is automatically formatted and linted on commit.
MIT
$ claude mcp add lit-starter-kit \
-- python -m otcore.mcp_server <graph>