How to Build an Inventory Management System with Next.js
Inventory management is the backbone of any business that sells physical products. Whether you run a small e-commerce store or a large warehouse operation, tracking stock levels, orders, and suppliers is essential.
In this guide, we will build a comprehensive inventory management dashboard using Next.js, Prisma, and PostgreSQL. You will learn how to implement stock tracking, low stock alerts, order management, and supplier management.
Database Schema
model Product {
id String @id @default(cuid())
name String
sku String @unique
description String?
category String
price Decimal
quantity Int @default(0)
minStock Int @default(10)
supplierId String?
supplier Supplier? @relation(fields: [supplierId], references: [id])
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
}
model Supplier {
id String @id @default(cuid())
name String
email String
phone String?
leadTime Int @default(7)
products Product[]
createdAt DateTime @default(now())
}Building the Inventory Dashboard
export async function getInventoryStats() {
const totalProducts = await prisma.product.count()
const lowStock = await prisma.product.count({ where: { quantity: { lte: prisma.product.fields.minStock } } })
const outOfStock = await prisma.product.count({ where: { quantity: 0 } })
const totalValue = await prisma.product.aggregate({ _sum: { price: true } })
return { totalProducts, lowStock, outOfStock, totalValue: totalValue._sum.price }
}Low Stock Alert Component
function LowStockAlerts({ products }: { products: Product[] }) {
const lowStockItems = products.filter(p => p.quantity <= p.minStock)
return (
<div className="rounded-xl bg-gray-900 p-4">
<h3 className="text-sm font-semibold text-white mb-3">Low Stock Alerts</h3>
<div className="space-y-2">
{lowStockItems.map(product => (
<div key={product.id} className="flex items-center justify-between py-2 border-b border-gray-800">
<div>
<p className="text-sm text-white">{product.name}</p>
<p className="text-xs text-gray-400">SKU: {product.sku}</p>
</div>
<div className="text-right">
<p className={`text-sm font-semibold ${
product.quantity === 0 ? 'text-red-400' : 'text-yellow-400'
}`}>{product.quantity} in stock</p>
<p className="text-xs text-gray-500">Min: {product.minStock}</p>
</div>
</div>
))}
</div>
</div>
)
}Cross-Selling: Ship Your Inventory Manager Faster
Our Inventory Manager template includes all of this and more — barcode support, purchase orders, warehouse zone management, stock transfers, and detailed inventory audit reports. It is fully production-ready.
Pair with Restaurant POS for food service inventory, or Cloud Cost Monitor for digital asset tracking. The templates integrate seamlessly into any business workflow.
Related Template
Try this production-ready starter kit to build your project faster.
| Product | SKU | Qty | Status | Category | Price |
|---|---|---|---|---|---|
| Wireless Mouse | WM-001 | 245 | high | Electronics | $29.99 |
| USB-C Hub | UCH-012 | 18 | low | Electronics | $49.99 |
| Standing Desk | SD-045 | 87 | medium | Furniture | $399.00 |
| Monitor Arm | MA-023 | 5 | low | Furniture | $89.00 |
| Keyboard TKL | KB-067 | 312 | high | Electronics | $79.99 |
| Webcam HD | WC-034 | 42 | medium | Electronics | $59.99 |
| Desk Lamp | DL-089 | 156 | high | Lighting | $34.99 |
| Cable Manager | CM-011 | 8 | low | Accessories | $12.99 |
Inventory Manager
Track stock, orders, and suppliers
Ready to Build?
Get started with our production-ready starter kits and ship your project faster.
Browse Starter Kits