ts-nextjs-tailwind-starter
🔋 Next.js + Tailwind CSS + TypeScript starter and boilerplate packed with useful development features
Top Related Projects
The React Framework
Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
The best way to start a full-stack, typesafe Next.js app
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
A utility-first CSS framework for rapid UI development.
Quick Overview
ts-nextjs-tailwind-starter is a comprehensive boilerplate for Next.js projects, featuring TypeScript and Tailwind CSS integration. It provides a solid foundation for building modern web applications with best practices and optimized configurations out of the box.
Pros
- Pre-configured with TypeScript, Next.js, and Tailwind CSS for rapid development
- Includes essential tools like ESLint, Prettier, and Husky for code quality and consistency
- Offers a collection of custom hooks and utility functions for common tasks
- Provides pre-built components and layouts for faster UI development
Cons
- May include unnecessary features or dependencies for simpler projects
- Requires familiarity with TypeScript, Next.js, and Tailwind CSS
- Opinionated folder structure might not suit all project requirements
- Regular maintenance needed to keep dependencies up-to-date
Code Examples
- Using the custom
useLoaded
hook:
import { useLoaded } from '@/hooks/useLoaded';
export default function Component() {
const isLoaded = useLoaded();
return (
<div className={isLoaded ? 'fade-in-start' : 'opacity-0'}>
Content here
</div>
);
}
- Utilizing the
clsxm
utility function for conditional classes:
import clsxm from '@/lib/clsxm';
const buttonClasses = clsxm(
'px-4 py-2 rounded',
isActive && 'bg-blue-500',
isDisabled && 'opacity-50 cursor-not-allowed'
);
- Using the
NextImage
component wrapper:
import NextImage from '@/components/NextImage';
export default function ImageComponent() {
return (
<NextImage
src="/path/to/image.jpg"
width={300}
height={200}
alt="Description"
/>
);
}
Getting Started
To use this starter template, follow these steps:
-
Clone the repository:
git clone https://github.com/theodorusclarence/ts-nextjs-tailwind-starter.git
-
Install dependencies:
cd ts-nextjs-tailwind-starter npm install
-
Run the development server:
npm run dev
-
Open
http://localhost:3000
in your browser to see the result.
Competitor Comparisons
The React Framework
Pros of next.js
- Official framework with extensive documentation and community support
- More comprehensive features and integrations out-of-the-box
- Regular updates and maintenance from Vercel team
Cons of next.js
- Steeper learning curve for beginners
- Less opinionated, requiring more setup for additional features
- Larger bundle size due to extensive feature set
Code Comparison
ts-nextjs-tailwind-starter:
import { AppProps } from 'next/app';
import '@/styles/globals.css';
function MyApp({ Component, pageProps }: AppProps) {
return <Component {...pageProps} />;
}
next.js:
import '@/styles/globals.css';
export default function App({ Component, pageProps }) {
return <Component {...pageProps} />;
}
The ts-nextjs-tailwind-starter example uses TypeScript and includes type annotations, while the next.js example is in JavaScript. The ts-nextjs-tailwind-starter provides a more structured starting point with TypeScript support, making it easier for developers to get started with a typed Next.js project. However, next.js offers more flexibility and can be customized to include TypeScript if desired.
Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
Pros of ui
- More comprehensive UI component library with a wider range of pre-built components
- Highly customizable and themeable components using CSS variables
- Better accessibility support out-of-the-box
Cons of ui
- Steeper learning curve due to more complex component structure
- Less opinionated about project structure and routing compared to ts-nextjs-tailwind-starter
- May require more setup and configuration for a complete application
Code Comparison
ts-nextjs-tailwind-starter:
import { Button } from '@/components/buttons/Button';
export default function HomePage() {
return <Button>Click me</Button>;
}
ui:
import { Button } from "@/components/ui/button"
export default function HomePage() {
return <Button variant="outline">Click me</Button>
}
The ui repository offers more customization options for components, such as the variant
prop in the Button example. However, ts-nextjs-tailwind-starter provides a simpler, more straightforward implementation that may be easier for beginners to understand and use.
Both repositories utilize TypeScript and Tailwind CSS, but ui focuses more on providing a comprehensive set of UI components, while ts-nextjs-tailwind-starter offers a complete project structure with routing and layout templates.
The best way to start a full-stack, typesafe Next.js app
Pros of create-t3-app
- Includes tRPC for type-safe API routes, enhancing full-stack TypeScript development
- Offers built-in authentication with NextAuth.js, simplifying user management
- Provides Prisma integration for database operations, streamlining data handling
Cons of create-t3-app
- More complex setup and steeper learning curve due to additional technologies
- Less focus on UI components and styling compared to ts-nextjs-tailwind-starter
- May include unnecessary features for simpler projects, potentially increasing bundle size
Code Comparison
ts-nextjs-tailwind-starter:
import clsxm from '@/lib/clsxm';
const Button = ({ className, ...rest }: ButtonProps) => (
<button
className={clsxm(
'inline-flex items-center rounded bg-primary-500 px-4 py-2 font-semibold text-white',
className
)}
{...rest}
/>
);
create-t3-app:
import { signIn, signOut, useSession } from "next-auth/react";
export const AuthShowcase: React.FC = () => {
const { data: sessionData } = useSession();
return (
<div className="flex flex-col items-center justify-center gap-4">
<p className="text-center text-2xl text-white">
{sessionData && <span>Logged in as {sessionData.user?.name}</span>}
</p>
<button
className="rounded-full bg-white/10 px-10 py-3 font-semibold text-white no-underline transition hover:bg-white/20"
onClick={sessionData ? () => void signOut() : () => void signIn()}
>
{sessionData ? "Sign out" : "Sign in"}
</button>
</div>
);
};
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
Pros of TanStack Query
- Focused on data fetching and state management
- Powerful caching and synchronization features
- Widely adopted and battle-tested in production environments
Cons of TanStack Query
- Steeper learning curve for beginners
- Requires additional setup and configuration
- Not a complete application starter kit like ts-nextjs-tailwind-starter
Code Comparison
ts-nextjs-tailwind-starter:
import { NextPage } from 'next';
import Layout from '@/components/layout/Layout';
const HomePage: NextPage = () => {
return <Layout>Home Page Content</Layout>;
};
TanStack Query:
import { useQuery } from '@tanstack/react-query';
function Example() {
const { isLoading, error, data } = useQuery({
queryKey: ['repoData'],
queryFn: () => fetch('https://api.github.com/repos/tannerlinsley/react-query').then(res => res.json())
});
}
The ts-nextjs-tailwind-starter provides a complete project structure with Next.js, TypeScript, and Tailwind CSS, making it easier to start a new project quickly. TanStack Query, on the other hand, focuses on efficient data fetching and state management, offering powerful tools for handling asynchronous data in React applications. While ts-nextjs-tailwind-starter is more suitable for rapid prototyping and general-purpose projects, TanStack Query excels in complex data-heavy applications that require advanced caching and synchronization capabilities.
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
Pros of tRPC
- Provides end-to-end typesafe APIs, enhancing developer experience and reducing runtime errors
- Offers automatic API documentation and client generation, streamlining development process
- Supports real-time subscriptions out of the box, enabling reactive applications
Cons of tRPC
- Requires a specific tech stack (TypeScript and React), limiting flexibility compared to the starter template
- Has a steeper learning curve for developers unfamiliar with RPC concepts
- May introduce additional complexity for smaller projects that don't require advanced API features
Code Comparison
ts-nextjs-tailwind-starter:
// pages/api/hello.ts
export default function handler(req: NextApiRequest, res: NextApiResponse) {
res.status(200).json({ name: 'John Doe' })
}
tRPC:
// server/routers/user.ts
export const userRouter = router({
getUser: publicProcedure
.input(z.string())
.query(({ input }) => {
return { name: 'John Doe', id: input }
}),
})
The ts-nextjs-tailwind-starter uses traditional Next.js API routes, while tRPC defines type-safe procedures that can be easily consumed on the client-side with full type inference.
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Core CSS framework with extensive utility classes
- Highly customizable and configurable
- Large community and ecosystem
Cons of Tailwind CSS
- Requires additional setup for Next.js and TypeScript integration
- Lacks pre-configured components and layouts
- Steeper learning curve for developers new to utility-first CSS
Code Comparison
ts-nextjs-tailwind-starter:
import clsxm from '@/lib/clsxm';
const Button = ({ className, ...rest }: ButtonProps) => (
<button
className={clsxm(
'rounded bg-primary-500 px-4 py-2 font-bold text-white hover:bg-primary-700',
className
)}
{...rest}
/>
);
Tailwind CSS (raw usage):
<button class="rounded bg-blue-500 px-4 py-2 font-bold text-white hover:bg-blue-700">
Click me
</button>
ts-nextjs-tailwind-starter provides a more structured approach with reusable components and TypeScript integration, while Tailwind CSS offers raw utility classes for direct use in HTML. The starter template simplifies development with Next.js and TypeScript, whereas Tailwind CSS requires manual setup for these technologies.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Next.js + Tailwind CSS + TypeScript Starter and Boilerplate
ð ts-nextjs-tailwind-starter
Next.js + Tailwind CSS + TypeScript starter packed with useful development features.
Made by Theodorus Clarence
Features
This repository is ð battery packed with:
- â¡ï¸ Next.js 14 with App Router
- âï¸ React 18
- ⨠TypeScript
- ð¨ Tailwind CSS 3 â Configured with CSS Variables to extend the primary color
- ð Pre-built Components â Components that will automatically adapt with your brand color, check here for the demo
- ð Jest â Configured for unit testing
- ð Absolute Import and Path Alias â Import components using
@/
prefix - ð ESLint â Find and fix problems in your code, also will auto sort your imports
- ð Prettier â Format your code consistently
- ð¶ Husky & Lint Staged â Run scripts on your staged files before they are committed
- ð¤ Conventional Commit Lint â Make sure you & your teammates follow conventional commit
- â° Release Please â Generate your changelog by activating the
release-please
workflow - ð· Github Actions â Lint your code on PR
- ð Automatic Branch and Issue Autolink â Branch will be automatically created on issue assign, and auto linked on PR
- ð¥ Snippets â A collection of useful snippets
- ð Open Graph Helper Function â Awesome open graph generated using og, fork it and deploy!
- ðº Site Map â Automatically generate sitemap.xml
- ð¦ Expansion Pack â Easily install common libraries, additional components, and configs.
See the ð feature details and changelog ð for more.
You can also check all of the details and demos on my blog post:
Getting Started
1. Clone this template using one of the three ways
-
Use this repository as template
Disclosure: by using this repository as a template, there will be an attribution on your repository.
I'll appreciate if you do, so this template can be known by others too ð
-
Using
create-next-app
pnpm create next-app -e https://github.com/theodorusclarence/ts-nextjs-tailwind-starter ts-pnpm
If you still want to use pages directory (is not actively maintained) you can use this command
npx create-next-app -e https://github.com/theodorusclarence/ts-nextjs-tailwind-starter/tree/pages-directory project-name
-
Using
degit
npx degit theodorusclarence/ts-nextjs-tailwind-starter YOUR_APP_NAME
-
Deploy to Vercel
2. Install dependencies
It is encouraged to use pnpm so the husky hooks can work properly.
pnpm install
3. Run the development server
You can start the server using this command:
pnpm dev
Open http://localhost:3000 with your browser to see the result. You can start editing the page by modifying src/pages/index.tsx
.
4. Change defaults
There are some things you need to change including title, urls, favicons, etc.
Find all comments with !STARTERCONF, then follow the guide.
Don't forget to change the package name in package.json
5. Commit Message Convention
This starter is using conventional commits, it is mandatory to use it to commit changes.
Projects using ts-nextjs-tailwind-starter
Are you using this starter? Please add your page (and repo) to the end of the list via a Pull Request. ð
Expansion Pack ð¦
This starter is now equipped with an expansion pack.
You can easily add expansion such as React Hook Form + Components, Storybook, and more just using a single command line.
Check out the expansion pack repository for the commands
App Router Update
Due to App Router update, the expansion pack is currently outdated. It will be updated in the future. You can still use them by copy and pasting the files.
Top Related Projects
The React Framework
Beautifully designed components that you can copy and paste into your apps. Accessible. Customizable. Open Source.
The best way to start a full-stack, typesafe Next.js app
🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
A utility-first CSS framework for rapid UI development.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot