precedent
An opinionated collection of components, hooks, and utilities for your Next.js project.
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
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
Authentication for the Web.
A utility-first CSS framework for rapid UI development.
Quick Overview
Precedent is a full-stack, opinionated, and production-ready Next.js template that comes with a set of pre-built components, utilities, and features to help developers kickstart their web application development. It aims to provide a solid foundation for building modern, scalable, and secure web applications.
Pros
- Opinionated and Batteries-Included: Precedent comes with a curated set of tools, libraries, and configurations, reducing the time and effort required to set up a new project.
- Robust and Production-Ready: The template is designed with best practices in mind, ensuring the resulting application is scalable, secure, and ready for deployment.
- Extensive Documentation: The project's documentation is comprehensive, covering everything from setup to advanced usage, making it easy for developers to get started and understand the various features.
- Active Community and Maintenance: The project has an active community and is regularly maintained, ensuring that issues are addressed, and new features are added.
Cons
- Opinionated Approach: While the opinionated nature of Precedent can be a pro for some developers, it may not suit the needs of those who prefer a more flexible or customizable approach.
- Steep Learning Curve: The project includes a significant number of pre-built components and features, which can be overwhelming for developers who are new to the ecosystem.
- Potential Vendor Lock-in: By using Precedent, developers may become dependent on the project's specific set of tools and libraries, which could make it more difficult to migrate to a different solution in the future.
- Performance Overhead: The inclusion of many pre-built components and features may result in a larger bundle size and potential performance overhead, which could be a concern for certain types of applications.
Getting Started
To get started with Precedent, follow these steps:
- Clone the repository:
git clone https://github.com/steven-tey/precedent.git
- Install the dependencies:
cd precedent
npm install
- Start the development server:
npm run dev
This will start the development server and open the application in your default web browser. From here, you can explore the various features and components provided by Precedent, and begin building your own application.
Competitor Comparisons
The React Framework
Pros of Next.js
- Extensive documentation and large community support
- More comprehensive features for building full-stack applications
- Regular updates and maintenance from Vercel
Cons of Next.js
- Steeper learning curve for beginners
- More complex setup for smaller projects
- Potentially overwhelming for simple websites
Code Comparison
Next.js:
// pages/index.js
export default function Home() {
return <h1>Welcome to Next.js!</h1>
}
Precedent:
// app/page.tsx
export default function Home() {
return <h1>Welcome to Precedent!</h1>
}
Key Differences
- Next.js is a full-featured framework, while Precedent is a starter template
- Precedent includes pre-configured tools like Tailwind CSS and Prisma
- Next.js offers more flexibility in routing and API creation
Use Cases
- Next.js: Large-scale applications, e-commerce sites, complex web apps
- Precedent: Quick prototypes, small to medium-sized projects, learning Next.js
Community and Support
- Next.js: Large, active community with extensive third-party resources
- Precedent: Smaller community, focused on the specific template implementation
Learning Curve
- Next.js: Moderate to steep, depending on prior React experience
- Precedent: Gentler introduction to Next.js concepts and best practices
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 customizable elements
- Actively maintained with frequent updates and contributions from the community
- Provides a CLI tool for easy component installation and customization
Cons of ui
- Requires more setup and configuration compared to Precedent's out-of-the-box solution
- Less opinionated, which may lead to more decision-making for developers
- Steeper learning curve for beginners due to its flexibility and extensive options
Code Comparison
ui:
import { Button } from "@/components/ui/button"
export function Example() {
return <Button variant="outline">Click me</Button>
}
Precedent:
import { Button } from "@/components/ui/button"
export default function Example() {
return <Button>Click me</Button>
}
The ui repository offers more customization options for components, such as the variant
prop in the Button example. Precedent provides a simpler, more straightforward implementation with fewer configuration options.
The best way to start a full-stack, typesafe Next.js app
Pros of create-t3-app
- Offers a more comprehensive full-stack development setup with tRPC, Prisma, and NextAuth.js
- Provides a CLI for easy project initialization and customization
- Includes built-in type safety and end-to-end typesafe APIs
Cons of create-t3-app
- Steeper learning curve due to the inclusion of multiple advanced technologies
- Less focus on UI components and design, requiring more setup for styling
- May be overkill for simpler projects that don't require all the included features
Code Comparison
create-t3-app:
import { createTRPCRouter } from "~/server/api/trpc";
import { exampleRouter } from "~/server/api/routers/example";
export const appRouter = createTRPCRouter({
example: exampleRouter,
});
Precedent:
import { NextApiRequest, NextApiResponse } from "next";
import prisma from "@/lib/prisma";
export default async function handler(
req: NextApiRequest,
res: NextApiResponse
) {
// API logic here
}
The code snippets highlight the difference in API setup between the two projects. create-t3-app uses tRPC for type-safe API routes, while Precedent uses traditional Next.js API routes with Prisma for database access.
🧙♀️ 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 generation, simplifying API management
- Supports real-time subscriptions, enabling efficient live data updates
Cons of tRPC
- Requires a steeper learning curve, especially for developers new to TypeScript
- Limited to TypeScript ecosystems, reducing flexibility for non-TypeScript projects
- May have performance overhead for very large-scale applications due to type inference
Code Comparison
tRPC:
export const appRouter = router({
greeting: publicProcedure
.input(z.object({ name: z.string() }))
.query(({ input }) => `Hello, ${input.name}!`),
});
Precedent:
export default function Home() {
return (
<Layout>
<h1>Welcome to Precedent</h1>
</Layout>
);
}
Summary
tRPC excels in providing type-safe APIs and real-time capabilities, while Precedent offers a more straightforward setup for Next.js projects. tRPC's code focuses on defining type-safe procedures, whereas Precedent emphasizes component-based structure. The choice between them depends on project requirements and team expertise.
Authentication for the Web.
Pros of next-auth
- Comprehensive authentication solution with support for multiple providers
- Extensive documentation and community support
- Flexible and customizable for various authentication scenarios
Cons of next-auth
- Steeper learning curve for beginners
- May include unnecessary features for simple projects
- Requires more setup and configuration
Code Comparison
next-auth:
import NextAuth from "next-auth"
import Providers from "next-auth/providers"
export default NextAuth({
providers: [
Providers.GitHub({
clientId: process.env.GITHUB_ID,
clientSecret: process.env.GITHUB_SECRET
}),
],
})
Precedent:
import { Auth } from "@supabase/auth-ui-react";
import { ThemeSupa } from "@supabase/auth-ui-shared";
<Auth
supabaseClient={supabase}
appearance={{ theme: ThemeSupa }}
theme="dark"
providers={["github"]}
redirectTo={`${getURL()}/dashboard`}
/>
Summary
next-auth offers a more comprehensive authentication solution with extensive features and provider support, making it suitable for complex projects. However, it may be overkill for simpler applications and requires more setup.
Precedent, on the other hand, provides a more streamlined approach using Supabase Auth, which is easier to implement for basic authentication needs but may lack some advanced features offered by next-auth.
The choice between the two depends on the project's specific requirements, complexity, and the developer's familiarity with the respective ecosystems.
A utility-first CSS framework for rapid UI development.
Pros of Tailwind CSS
- Extensive utility-based CSS framework with a large ecosystem
- Highly customizable and configurable
- Well-documented with a large community and support base
Cons of Tailwind CSS
- Steeper learning curve for developers new to utility-first CSS
- Requires additional setup and configuration
- Can lead to verbose HTML markup
Code Comparison
Tailwind CSS:
<button class="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded">
Button
</button>
Precedent:
<Button variant="default" size="lg">
Button
</Button>
Summary
Tailwind CSS is a comprehensive utility-first CSS framework, offering extensive customization options and a large ecosystem. It provides granular control over styling but may require more setup and lead to verbose HTML. Precedent, on the other hand, is a more opinionated starter template that includes pre-built components and integrations, making it quicker to get started with a full-stack application. While Tailwind CSS offers more flexibility, Precedent provides a more streamlined development experience for those looking to rapidly prototype or build Next.js applications with a predefined stack.
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
Precedent
Building blocks for your Next project
Introduction · One-click Deploy · Tech Stack + Features · Author
Introduction
Precedent is an opinionated collection of components, hooks, and utilities for your Next.js project.
One-click Deploy
You can deploy this template to Vercel with the button below:
You can also clone & create this repo locally with the following command:
npx create-next-app precedent --example "https://github.com/steven-tey/precedent"
Then, install the dependencies with your package manager of choice:
npm i
yarn
pnpm i
Tech Stack + Features
Frameworks
- Next.js â React framework for building performant apps with the best developer experience
- Auth.js â Handle user authentication with ease with providers like Google, Twitter, GitHub, etc.
- Prisma â Typescript-first ORM for Node.js
Platforms
- Vercel â Easily preview & deploy changes with git
- Vercel Postgres â Serverless Postgres at the Edge
UI
- Tailwind CSS â Utility-first CSS framework for rapid UI development
- Radix â Primitives like modal, popover, etc. to build a stellar user experience
- Framer Motion â Motion library for React to animate components with ease
- Lucide â Beautifully simple, pixel-perfect icons
next/font
â Optimize custom fonts and remove external network requests for improved performanceImageResponse
â Generate dynamic Open Graph images at the edge
Hooks and Utilities
useIntersectionObserver
â React hook to observe when an element enters or leaves the viewportuseLocalStorage
â Persist data in the browser's local storageuseScroll
â React hook to observe scroll position (example)nFormatter
â Format numbers with suffixes like1.2k
or1.2M
capitalize
â Capitalize the first letter of a stringtruncate
â Truncate a string to a specified lengthuse-debounce
â Debounce a function call / state update
Code Quality
- TypeScript â Static type checker for end-to-end typesafety
- Prettier â Opinionated code formatter for consistent code style
- ESLint â Pluggable linter for Next.js and TypeScript
Miscellaneous
- Vercel Analytics â Track unique visitors, pageviews, and more in a privacy-friendly way
Author
- Steven Tey (@steventey)
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
🧙♀️ Move Fast and Break Nothing. End-to-end typesafe APIs made easy.
Authentication for the Web.
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