omni-rest-nextjs-example
v1.0.0
Published
Next.js example using omni-rest for auto-generated REST APIs
Readme
omni-rest Next.js Example
A complete Next.js application using omni-rest for auto-generated REST APIs with React hooks and components.
Setup
- Install dependencies:
npm install- Set up the database:
npm run db:push
npm run db:generate- Seed the database:
npm run db:seed- Start the development server:
npm run devThe app will run on http://localhost:3000
Features
- ✅ Auto-generated REST API routes
- ✅ React hooks for data fetching (
useMaster) - ✅ Drop-in CRUD components (
MasterTable) - ✅ TypeScript support
- ✅ Tailwind CSS styling
- ✅ Full CRUD operations (Create, Read, Update, Delete)
API Routes
All API endpoints are automatically available at /api/[...prismaRest]:
GET /api/departments- List departmentsPOST /api/departments- Create departmentGET /api/departments/:id- Get department by IDPUT /api/departments/:id- Update departmentPATCH /api/departments/:id- Partially update departmentDELETE /api/departments/:id- Delete department
Same for categories, products, and cities.
Components
useMaster Hook
const { data, loading, error, create, update, remove } = useMaster({
model: "departments",
page: 1,
limit: 20
});MasterTable Component
<MasterTable
model="departments"
fields={["name", "description"]}
title="Department Management"
/>This provides a complete CRUD table with inline editing and creation.
Demo Pages
/- Home page with overview/masters/departments- Full CRUD demo for departments
