Automatic API Generator for Next.js Applications
Quickwire automatically generates Next.js API routes and TypeScript client functions from your backend functions, eliminating boilerplate code and ensuring type safety.
Note: This root directory is a test Next.js application. The actual Quickwire npm module codebase is located in the
scripts
folder. Please go there for the complete codebase and documentation.
# Install Quickwire
npm install quickwire --save-dev
Update your package.json
:
{
"packageManager": "[email protected]", // Your npm version can be checked with "npm --version"
"scripts": {
"quickwire": "quickwire --watch",
"nextdev": "next dev --turbopack",
"dev": "turbo run quickwire nextdev --parallel",
"prebuild": "quickwire",
"build": "next build --turbopack"
},
}
Add TypeScript path mapping to your tsconfig.json
:
{
"compilerOptions": {
"paths": {
"quickwired/*": ["./quickwired/*"],
"@/*": ["./src/*"]
}
}
}
- Write backend function
- Create API route manually
- Write client function manually
- Handle types manually
- Manage errors manually
- Write API documentation manually
Result: Lots of boilerplate, potential type mismatches, manual maintenance
- Write backend function
- Run
npm run dev
- β¨ Everything else is auto-generated!
Result: 70% less code, 100% type safety, zero maintenance, automatic Swagger documentation
Quickwire includes a complete authentication system with JWT tokens and role-based access control:
- User Authentication: Signup and login with JWT tokens
- Role-Based Access: USER and ADMIN roles with appropriate permissions
- Protected Routes: Client-side protection for authenticated pages
- Todo Management: Users can only see/edit their own todos, admins can manage all
- Admin Panel: Dedicated interface for system administration
signup({ name, email, password })
- Create new user accountlogin({ email, password })
- Authenticate user and return JWT tokengetProfile()
- Get authenticated user profileupdateProfile({ name?, email? })
- Update user profilechangePassword({ currentPassword, newPassword })
- Change user password
getTodos({ completed? })
- Get user's todos (users only see their own)getAllTodos({ userId?, completed? })
- Get all todos (admin only)createTodo({ title, description?, userId? })
- Create todo (users create for themselves, admins can create for others)updateTodo({ id, title?, description?, completed? })
- Update todo (users can only update their own)deleteTodo({ id })
- Delete todo (users can only delete their own)toggleTodo({ id })
- Toggle todo completion status
getUsers({ role? })
- Get all users (admin only)getUserDetails({ id })
- Get detailed user information (admin only)createUser({ name, email, password, role? })
- Create user (admin only)updateUser({ id, name?, email?, role? })
- Update user (admin only)deleteUser({ id })
- Delete user (admin only)getDashboardStats()
- Get system statistics (admin only)
// src/backend/users.ts
export async function getUser(params: { id: string }) {
return prisma.user.findUnique({
where: { id: params.id }
});
}
export async function createUser(params: {
name: string;
email: string;
}) {
return prisma.user.create({ data: params });
}
// src/app/users/page.tsx
"use client";
import { getUser, createUser } from "quickwired/users";
export default function UsersPage() {
const handleGetUser = async () => {
// β¨ Fully typed, auto-generated API call
const user = await getUser({ id: "123" });
console.log(user);
};
const handleCreateUser = async () => {
const newUser = await createUser({
name: "John Doe",
email: "[email protected]"
});
console.log(newUser);
};
return (
<div>
<button onClick={handleGetUser}>Get User</button>
<button onClick={handleCreateUser}>Create User</button>
</div>
);
}
Quickwire automatically generates:
- β
Next.js API routes in
src/app/api/(quickwired)/
- β
TypeScript client functions in
quickwired/
- β Full type safety and error handling
- β HTTP method detection (GET/POST/PUT/DELETE)
# 1. Check npm version (requires npm 11.3.0 or higher)
npm --version
# 2. If needed, update npm
npm install -g npm@latest
# 3. Install packages
npm install quickwire --save-dev
# 4. Update package.json scripts (see above)
# 5. Set up environment variables
# Copy .env.example to .env and update values
# 6. Run database migrations
npx prisma migrate dev
# 7. Seed the database with demo data
npm run seed
# 8. Start development
npm run dev
# 9. Write functions in src/backend/
# 10. Import from quickwired/* in your components
- Admin User: [email protected] / password123
- Regular User: [email protected] / password123
- π Faster Development: No more boilerplate API routes
- π Type Safety: End-to-end TypeScript support
- π Hot Reload: Automatic regeneration during development
- π― Zero Config: Works out of the box
- π± Modern: Built for Next.js 13+ App Router
Ready to eliminate API boilerplate? Install Quickwire and watch your development speed up! β‘