Skip to content

A Turborepo starter template with Next.js, Nextra, Storybook, and a shared pre-configured shadcn/ui package, powered by Bun and Biome

License

Notifications You must be signed in to change notification settings

gmickel/turborepo-shadcn-nextjs

Repository files navigation

A Turborepo starter template with Next.js, Nextra, and a shared pre-configured shadcn/ui package, powered by Bun, Vitest, Playwright, Storybook and Biome πŸš€

Static Badge CI Known Vulnerabilities License Bun

Note

This repo uses bun as the package manager. 🐰

How to use πŸ› οΈ

Clone the repository:

git clone https://github.com/gmickel/turborepo-shadcn-nextjs.git

Install dependencies:

cd turborepo-shadcn-nextjs
bun install

Add UI components ✨

Use the pre-made script:

bun ui:add:component <component-name>

This works just like the add command in the shadcn/ui CLI. 🎨

What's inside? πŸ“¦

This Turborepo includes the following:

Apps and Packages πŸ“š

  • @repo/docs: a placeholder documentation site powered by Nextra 3 alpha πŸ“–
  • @repo/web: the main Next.js web application 🌐
  • @repo/ui: core React components and design system shared by both web and docs applications (🎨 powered by shadcn/ui)
  • @repo/utils: shared React utilities πŸ› οΈ
  • @repo/tsconfig: shared tsconfig.jsons used throughout the monorepo πŸ›‘οΈ

Each package and app is 100% TypeScript. πŸ’ͺ

Utilities 🧰

This Turborepo has some additional tools already set up for you:

  • TypeScript for static type checking βœ…
  • Biome for code linting, formatting, and fixing 🌿
  • Vitest for unit tests πŸ§ͺ
  • Playwright for end-to-end tests πŸ§ͺ
  • Changesets for managing versioning, changelogs, and publishing πŸ“
  • Storybook for component development and documentation πŸ“š

Storybook πŸ“š

This Turborepo includes Storybook for component development and documentation. Storybook is set up for both the @repo/web and @repo/ui packages, allowing the development and showcasing of components from both your main application and your shared UI library.

To run Storybook:

bun storybook

This will start Storybook and open it in your default browser.

Story Location

Storybook is configured to find stories in the following locations:

  • apps/storybook/src/**/*.mdx
  • apps/storybook/src/**/*.stories.@(js|jsx|mjs|ts|tsx)
  • apps/web/src/**/*.stories.@(js|jsx|mjs|ts|tsx)
  • packages/ui/src/**/*.stories.@(js|jsx|mjs|ts|tsx)

This configuration allows you to write stories for components in both your web application and your shared UI library.

Storybook Addons

This setup includes several useful Storybook addons:

  • @storybook/addon-links: For linking between stories
  • @storybook/addon-essentials: A curated set of addons for a great developer experience
  • @storybook/addon-onboarding: For onboarding new users
  • @storybook/addon-interactions: For testing component interactions
  • @storybook/addon-themes: For theme switching in Storybook
  • @storybook/addon-styling-webpack: For handling CSS and PostCSS in Storybook

Useful commands πŸ€–

  • bun build - Build all apps and packages
  • bun dev - Develop all apps and packages
  • bun dev:ui - Develop all apps and packages and display the output in Turbo's new experimental UI
  • bun test - Run all tests with vitest
  • bun test:cov - Run all unit tests with vitest and generate a coverage report
  • bun test:cov:ui - Run all unit tests with vitest and display the vitest UI
  • bun test:e2e - Run all end-to-end tests with playwright
  • bun lint - Lint and format all packages
  • bun lint:fix - Lint, format, and fix all packages
  • bun changeset - Generate a changeset πŸ§‘β€πŸ”§ - WIP
  • bun clean - Clean up all node_modules and dist folders (runs each package's clean script)
  • bun ui:add:component - Add a shadcn/ui component to the @repo/ui package
  • bun storybook - Run Storybook for component development and documentation

Add a new app or package πŸ“¦

Turborepo offers a simple command to add new apps or packages to the monorepo. To add a new app, run the following command:

bun turbo gen workspace [--name <app-name>]

You will be prompted to choose the name and workspace type (app or package) to use.

You can copy an existing app or package with:

bun turbo gen workspace [--name <app-name>] --copy

You will be prompted to choose the name and workspace type (app or package) of the new app and which app or package to copy.

Note

Remember to run bun install after copying an app. ⚠️

CI πŸ€–

CI

This Turborepo uses GitHub Actions for CI. πŸ€–

It comes preconfigured with the following workflow that runs on every push or pull request to the main branch:

  1. Setup: Checks out the code and sets up Bun.
  2. Install: Installs all dependencies using Bun.
  3. Build: Builds all apps and packages in the monorepo.
  4. Unit Tests: Runs all unit tests using Vitest.
  5. E2E Tests: Installs Playwright browsers and runs end-to-end tests using Playwright.
  6. Lint: Performs linting and formatting checks using Biome.

Automated Dependency Management & Contributor Recognition πŸ€–

This template includes some useful automation tools:

1. Dependabot Configuration πŸ”„

Keeps dependencies up-to-date automatically with daily checks and update rules.

View Dependabot Config

2. Auto-merge for Dependabot PRs πŸ”€

Can automatically merges patch updates from Dependabot to reduce manual work.

View Auto-merge Workflow

For the auto-merge workflow:

  • Go to your repository's Settings > Actions > General.
  • Under "Workflow permissions", select "Read and write permissions".
  • Check "Allow GitHub Actions to create and approve pull requests".
  • Save the changes.
  • Optionally, create a Personal Access Token (PAT) with repo scope and add it as a repository secret named GITHUB_TOKEN for enhanced security.

3. Automated Contributors List πŸ™Œ

Maintains an up-to-date list of contributors in your README.

View Contributors Workflow

πŸš€ Getting Started

  1. Dependabot is active out-of-the-box. Review and adjust the config as needed.
  2. Ensure proper permissions for the auto-merge workflow.
  3. To read more about the contributors list, see the contributors-readme-action README.

Versioning and Publishing packages πŸ“¦

πŸ§‘β€πŸ”§ WIP

For more information, refer to the official Changesets documentation.

Useful Links and Thanks πŸ™

Build Tools and Configuration

Frameworks and Libraries

Testing Tools

Development Tools

Contributors πŸ‘¨β€πŸ’»

gmickel
Gordon Mickel

About

A Turborepo starter template with Next.js, Nextra, Storybook, and a shared pre-configured shadcn/ui package, powered by Bun and Biome

Topics

Resources

License

Stars

Watchers

Forks

Packages