Type-safe shared models and reusable props interfaces for TypeScript and React projects.
@ahmnouira/props helps you avoid repeating common prop types (onClick, value, loading, list, etc.) and gives you a small set of domain models (User, Role, Status, Entity) you can reuse across apps.
- 🧠 Simple and intuitive
- 🔒 Fully type-safe (TypeScript-first)
- ⚡ Lightweight and dependency-free
- 🔌 Works with Next.js, and any TS project
- 🧩 Reusable props and utilities
npm install @ahmnouira/props- Domain models for application data:
EntityUserRoleStatus
- Composable prop types for React/TS components:
- Base utility props like
ValueProps<T>,ChangeProps<T>,ClickProps,LoadingProps,ListProps<T> - Combined props like
TextClickProps,ButtonProps,MenuItemsProps,FieldProps,DialogProps<T>
- Base utility props like
import type {
User,
Role,
Status,
ValueChangeProps,
ButtonProps,
DialogProps,
} from "@ahmnouira/props";
const role: Role = "admin";
const status: Status = "online";
const user: User = {
id: "u_1",
role,
status,
verified: true,
};
type NameInputProps = ValueChangeProps<string> & {
label: string;
};
type ConfirmDialogProps = DialogProps<boolean> & ButtonProps;Entity: base entity shape withid, optionalcreatedAt, optionalupdatedAtUser: extends the user entity with optional metadata such asrole,status,phone,verifiedRole:"admin" | "user" | "other"Status:"online" | "busy" | "offline" | "all"
ValueProps<T>:value?: TChangeProps<T>:onChange?: (value: T) => voidValueChangeProps<T>: composition ofValueProps<T>+ChangeProps<T>ClickProps:onClick?: () => voidListProps<T>:list?: T[]LoadingProps:loading?: boolean
ButtonProps:DisabledProps & TitleProps & ClickPropsTextClickProps:TextProps & ClickPropsFieldProps:LoadingProps & ErrorsProps & ValueProps & { shake?: boolean; props?: any }DialogProps<T>:CloseProps & { onChange: (value: T) => void; value: T }
Check examples/basic-usage.ts for a complete typed example that combines:
- shared
Usermodel - reusable value/change props
- composed dialog props
- strongly typed list/menu usage
Additional examples:
examples/react-example.tsx: reusable React components typed with this libraryexamples/nextjs-example.tsx: Next.js page-level example with typed dialog and user model
import { LinkProps } from "@ahmnouira/props";
export const SignInButton = ({
href = "/auth/login",
text = "Sign In",
}: LinkProps) => {
return (
<a
className="h-10 flex items-center px-6 rounded-full border border-zinc-200/80 bg-white/80 text-[10px] font-bold tracking-[0.2em] uppercase transition-all hover:bg-black hover:text-white dark:border-zinc-800 dark:bg-zinc-900 dark:hover:bg-white dark:hover:text-black"
href={href}
>
{text}
</a>
);
};- This package is type-first and lightweight.
- It is framework-agnostic but especially useful with React and Next.js component props.
- All exports are available from the package root:
import type { User, ButtonProps, ValueChangeProps } from "@ahmnouira/props";MIT