# CRM

A free, open-source CRM for small B2B sales teams of 3 to 15 people, built with Next.js 16, TypeScript and PostgreSQL. It includes companies, contacts and deals on a drag-and-drop pipeline, a timeline of calls, emails, meetings and notes, tasks with a Today view, win and loss reasons, reports and CSV import and export.

- Framework: Next.js (JavaScript)
- Category: Apps / CRM
- Creates: a server app and a PostgreSQL database on the Shared tier (1 GB)
- Plan: Lite or above
- Price: Free
- Author: Light Cloud
- Page: https://templates.light-cloud.com/apps/crm/crm-template-nextjs-postgresql
- Updated: 2026-11-21

## Features

- Deals on a kanban board in Lead, Qualified, Proposal sent and Negotiation, with a count and total per column
- Move a card with the mouse, press and hold on touch, Space and the arrow keys, or the Move menu on each card
- Marking a deal won or lost asks for a reason and an optional note, and a closed deal can be reopened
- One timeline of calls, emails, meetings and notes: an entry logged on a deal also shows on its contact and company
- Today lists your overdue and due tasks, the next 7 days and your open deals expected to close in the next 14 days
- Reports on pipeline by stage and owner, value won per month for six months, and win and loss reasons over 90 days
- CSV import that reads Excel, Outlook, Google Contacts and HubSpot headers and skips emails already in the CRM
- Workspaces with owner, admin and member roles, invitations by email or link, and a demo workspace removed in one click

## What you need

- A paid plan: deploying creates a PostgreSQL database, which the Free plan does not include
- To run it locally: Node.js 22.12 or newer, npm, and Docker for a local PostgreSQL
- No API keys: it starts with nothing to configure
- Optional: RESEND_API_KEY and EMAIL_FROM to send invitations and password resets; without them emails go to the server log
- Optional: STRIPE_SECRET_KEY, STRIPE_WEBHOOK_SECRET, STRIPE_PRICE_PRO and STRIPE_PRICE_BUSINESS for paid plans with seat limits

## About

The CRM sits on the sign-in, teams, admin panel and Stripe billing of the Next.js SaaS starter. Every CRM change goes through a server action in src/app/(app)/crm-actions.ts that checks the role, then through src/lib/crm/records.ts, which validates with zod and scopes each row to the active workspace. The first things to change are the stages and win and loss reasons in src/lib/crm/constants.ts and the currency and locale (GBP and en-GB) in src/lib/format.ts. npm start applies the SQL migrations under a PostgreSQL advisory lock and seeds the demo workspace once, marking every seeded row so Remove demo data deletes only those. On Light Cloud the deploy sets DATABASE_URL and a random AUTH_SECRET, and each push to your copy redeploys.

## Variables

- `AUTH_SECRET`: generated

## Questions

### Is there a free open-source CRM template for Next.js?

Yes. This CRM is MIT licensed and built with Next.js 16, PostgreSQL and Drizzle ORM. Without Stripe keys every feature is on and there is no seat limit.

### How do I import contacts from Excel or HubSpot into a CRM?

Save the sheet as CSV and use Contacts, Import CSV as an owner or admin. It recognises the usual Excel, Outlook, Google Contacts and HubSpot column names, creates companies by name and skips emails that are already in the CRM.

### How do I change the pipeline stages?

Edit STAGES, OPEN_STAGES and STAGE_LABELS in src/lib/crm/constants.ts. The board, the list view, the reports and the deal form all read from there, and Won and Lost are the two closing stages.

### Can the CRM show amounts in euros or dollars instead of pounds?

Yes. Change CURRENCY and LOCALE at the top of src/lib/format.ts, and set TZ for the time zone that Today and due dates use.

### Can I self-host this CRM without Light Cloud?

Yes. It has no Light Cloud code: any host with Node.js 22.12 and PostgreSQL runs it once DATABASE_URL and AUTH_SECRET are set, with npm ci && npm run build and then npm start.
