We use tracking cookies to understand how you use the product and help us improve it. For more information on how we store cookies, read our  privacy policy.

Naming Conventions

File, component, and code naming patterns

Consistent naming makes code readable and maintainable. Here are Plainform's conventions.

Files & Folders

TypeConventionExample
ComponentsPascalCaseHero.tsx, PricingCard.tsx
UtilitiescamelCaseutils.ts, formatDate.ts
TypesPascalCase + suffixBlogInterfaces.ts
Routeskebab-casesign-in/, blog-post/
Contentkebab-casegetting-started.mdx
API Routesroute.tsapp/api/users/route.ts

Code Elements

Interfaces & Types

Always prefix interfaces with I

Interface naming
✅ Good
interface IUser {
  id: string;
  name: string;
}

interface IPricingCardProps {
  title: string;
  price: number;
}

type Status = 'pending' | 'active' | 'inactive';

❌ Bad
interface User { }
interface PricingCardProps { }

Functions

Function naming
// Components: PascalCase
export function Hero() { }

// Utilities: camelCase with verbs
export function formatDate(date: Date): string { }
export function slugify(text: string): string { }

// Event handlers: handle prefix
const handleClick = () => { };
const handleSubmit = (e: FormEvent) => { };

// Booleans: is/has/can/should prefix
function isAuthenticated(): boolean { }
function hasPermission(user: IUser): boolean { }

Variables

Variable naming
// Regular: camelCase
const userName = 'John';
const totalPrice = 100;

// Booleans: is/has/can prefix
const isOpen = true;
const hasAccess = false;

// Config objects: camelCase
export const siteConfig = { };
export const stripe = new Stripe();

// True constants: SCREAMING_SNAKE_CASE
const MAX_FILE_SIZE = 5 * 1024 * 1024;
const API_VERSION = '2024-01-01';

// Locale variables: suffix with Locale
const heroLocale = locale?.homePage?.heroSection;

Database (Prisma)

schema.prisma
// Models: PascalCase, singular
model User {
  id        String @id
  firstName String
  orders    Order[]
}

// Fields: camelCase
// Relations: camelCase, descriptive

API Routes

route.ts
// File: route.ts
export async function GET(req: Request) { }
export async function POST(req: Request) { }

// Schemas: suffix with Schema
export const signInSchema = z.object({ });

Quick Reference

Components: Hero.tsxexport function Hero()
Utilities: utils.tsexport function formatDate()
Interfaces: Always prefix with IIUser, IProps
Booleans: isOpen, hasAccess, canEdit
Constants: siteConfig, MAX_SIZE
Routes: sign-in/, blog-post/

ESLint and Prettier enforce most of these automatically. Run npm run lint before committing.

How is this guide ?

Last updated on