Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

@itboom/next-types 🚀

@itboom/next-types is a global TypeScript utility that provides strongly-typed, collision-safe prop types for Next.js App Router components.

It includes three globally available types — NextPageProps, NextLayoutProps, and NextRouteProps — optimized for use in asynchronous environments where params and searchParams are promises.


Table of Contents

  1. Features ✨
  2. Installation 📦
  3. Usage 🔧
  4. Examples
  5. API Reference 📚
  6. License 📄
  7. Contributing 🤝
  8. Author 👤

Features ✨

  • Two usage modes: Import types or enable them globally via tsconfig.json
  • 🧠 Async-first design: All props are promise-wrapped for await support
  • 🧩 Collision-safe names: No clashes with LayoutProps from other libraries
  • 🔍 Clear intent: Names follow NextPageProps, NextLayoutProps, NextRouteProps
  • Lightweight: Types only, zero runtime code

Installation 📦

Bun

bun add @itboom/next-types

npm

npm install @itboom/next-types

Usage 🔧

Option 1: Import types

importtype{NextPageProps,NextLayoutProps,NextRouteProps}from'@itboom/next-types';

Option 2: Enable global types

In your tsconfig.json:

{
"compilerOptions": {
"types": ["@itboom/next-types"]
}
}

If IntelliSense doesn’t work immediately, reload VS Code or restart the TS server.


Examples

Page Props

// /app/product/[id]/page.tsxconstPage=async({ params, searchParams }: NextPageProps<{id: string},{lang: string}>)=>{const{ id }=awaitparams;const{ lang }=awaitsearchParams;return<div>Product ID: {id} | Language: {lang}</div>;};

Layout Props

// /app/[locale]/layout.tsxconstLayout=async({ children, params }: NextLayoutProps<{locale: string}>)=>{const{ locale }=awaitparams;return(<htmllang={locale}><body>{children}</body></html>);};

Route Props

// /app/api/user/[id]/route.tsconstGET=async({ params }: NextRouteProps<{id: string}>)=>{const{ id }=awaitparams;returnnewResponse(`User ID: ${id}`);};

API Reference 📚

NextPageProps<Params, SearchParams>

Props type for page.tsx components:

  • params: Promise<Params> – dynamic route segments
  • searchParams: Promise<SearchParams> – parsed query string

NextLayoutProps<Params>

Props type for layout.tsx components:

  • params: Promise<Params>
  • children: React.ReactNode

NextRouteProps<Params>

Props type for route.ts handlers:

  • params: Promise<Params>

License 📄

MIT License. See the LICENSE file for details.


Contributing 🤝

Issues, ideas, and PRs are welcome — help improve typing hygiene for the Next.js ecosystem!


Author 👤

Created by Bohdan Kulinchenko
Founder of itboom.dev
GitHub: @ITBoomDev


Enjoy using @itboom/next-types — and type your props the clean and correct way. 🔥

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors