A full-featured real-time chat application built with Next.js and Prisma, showcasing Igniter.js's SSE-based real-time features for instant updates.
Discover other templates that might interest you based on similar technologies and use cases.
A full-featured application built using the latest Next.js conventions with end-to-end type safety powered by Igniter.js.
Build your SaaS in a weekend. Every SaaS starts with the same basic code - stop reinventing the wheel.
A modern full-stack application built with TanStack Start featuring type-safe routing and server functions.
@felipebarcelospro
Fundador e Criador de Conteúdo na Vibe Dev | AI | Blockchain | Inteligência Artificial | Web3 | Startups | Crypto | SaaS | Micro-SaaS
Welcome to the Igniter.js Real-Time Chat Example! This project demonstrates how to build a full-stack, type-safe, real-time chat application using Igniter.js, Next.js, and Prisma. It serves as a practical example of how to leverage Igniter.js for building modern, high-performance web applications.
Before you begin, ensure you have the following installed:
Follow these steps to get your project up and running:
Clone the Repository
git clone https://github.com/felipebarcelospro/todo-igniter-project.git
cd todo-igniter-project
Install Dependencies
bun install
Configure Environment Variables
Create a .env
file in the root of the project and add your database connection URL:
# .env
DATABASE_URL="postgresql://user:password@localhost:5432/mydatabase?schema=public"
Run Database Migrations
bun prisma db push
Run the Development Server
bun dev
This command starts the Next.js development server. Your application will be available at http://localhost:3000
.
This starter deeply integrates Igniter.js with the Next.js App Router to create a real-time chat application.
The entry point for all API requests is the catch-all route handler located at src/app/api/[[...all]]/route.ts
. This file uses the nextRouteHandlerAdapter
from Igniter.js to expose the entire API.
// src/app/api/[[...all]]/route.ts
import { AppRouter } from '@/igniter.router'
import { nextRouteHandlerAdapter } from '@igniter-js/core/adapters'
// The adapter creates GET, POST, etc. handlers from your Igniter.js router.
export const { GET, POST, PUT, DELETE } = nextRouteHandlerAdapter(AppRouter)
The back-end API logic is defined using Igniter.js.
src/igniter.ts
)src/igniter.router.ts
)src/features/[feature]/controllers/
)Igniter.js automatically generates a type-safe client based on your API router.
api
object in src/igniter.client.ts
is your gateway to the back-end.Server Component Usage:
// app/some-server-page/page.tsx
import { api } from '@/igniter.client';
export default async function SomePage() {
// Direct, type-safe API call
const data = await api.example.health.query();
return <div>Status: {data.status}</div>;
}
Client Component Usage:
// components/SomeClientComponent.tsx
'use client';
import { api } from '@/igniter.client';
export function SomeClientComponent() {
// Type-safe hook for data fetching, caching, and revalidation
const { data, isLoading } = api.example.health.useQuery();
if (isLoading) return <div>Loading...</div>;
return <div>Status: {data?.status}</div>;
}
The project follows a feature-based architecture combined with Next.js conventions.
src/
├── app/ # Next.js App Router pages and layouts
│ └── api/ # API route handlers
│ └── [[...all]]/
│ └── route.ts # Igniter.js API entry point
├── components/ # Shared, reusable UI components
├── features/ # Business logic, grouped by feature
│ └── message/
│ ├── controllers/ # API endpoint definitions
│ └── presentation/ # React components for the feature
├── services/ # Service initializations (Prisma, etc.)
├── igniter.ts # Igniter.js core instance
├── igniter.client.ts # Auto-generated type-safe API client
├── igniter.router.ts # Main API router
└── layout.tsx # Root layout, includes providers
bun dev
: Starts the development server.bun build
: Builds the application for production.bun start
: Starts the production server.bun lint
: Runs the linter.To learn more about Igniter.js and its powerful features, check out the official resources:
This starter is licensed under the MIT License.