Lancer un SaaS ne demande plus des mois de développement. Avec les bons outils — Next.js 14, Stripe, Prisma, Vercel — vous pouvez avoir un produit fonctionnel en 48h. Ce guide détaille chaque étape, du premier commit au déploiement en production.
Jour 1 — Les fondations (heures 0-12)
Étape 1 : Initialiser le projet
Commencez par créer un projet Next.js 14 avec TypeScript, Tailwind CSS et App Router :
npx create-next-app@14 mon-saas \
--typescript --tailwind --eslint --app \
--src-dir --import-alias "@/*"
cd mon-saas
# Installer les dépendances essentielles
npm install prisma @prisma/client next-auth
npm install stripe @stripe/stripe-js
npm install zod react-hook-form
npm install @neuraapi/sdkÉtape 2 : Configurer la base de données
Prisma offre une couche ORM intuitive. Initialisez-le avec PostgreSQL :
// prisma/schema.prisma
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model User {
id String @id @default(cuid())
email String @unique
name String?
password String
plan String @default("starter")
apiKey String @unique @default(cuid())
createdAt DateTime @default(now())
projects Project[]
}Étape 3 : Implémenter l'authentification
NextAuth.js est le choix standard pour Next.js. Configurez-le avec credentials :
// src/lib/auth.ts
import NextAuth from 'next-auth'
import CredentialsProvider from 'next-auth/providers/credentials'
import { prisma } from './db'
import bcrypt from 'bcryptjs'
export const { handlers, auth, signIn, signOut } = NextAuth({
providers: [
CredentialsProvider({
credentials: {
email: { label: 'Email', type: 'email' },
password: { label: 'Mot de passe', type: 'password' },
},
async authorize(credentials) {
const user = await prisma.user.findUnique({
where: { email: credentials?.email as string },
})
if (!user) return null
const valid = await bcrypt.compare(
credentials?.password as string, user.password
)
if (!valid) return null
return { id: user.id, email: user.email, name: user.name }
},
}),
],
session: { strategy: 'jwt' },
pages: { signIn: '/login' },
})Jour 2 — La facturation et le déploiement
Étape 4 : Intégrer Stripe
// src/app/api/stripe/checkout/route.ts
import { NextRequest, NextResponse } from 'next/server'
import { auth } from '@/lib/auth'
import Stripe from 'stripe'
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!)
export async function POST(req: NextRequest) {
const session = await auth()
if (!session?.user) {
return NextResponse.json({ error: 'Unauthorized' }, { status: 401 })
}
const { plan } = await req.json()
const checkoutSession = await stripe.checkout.sessions.create({
mode: 'subscription',
payment_method_types: ['card'],
customer_email: session.user.email!,
line_items: [{ price: PLANS[plan].priceId, quantity: 1 }],
success_url: `${process.env.NEXT_URL}/dashboard?success=true`,
cancel_url: `${process.env.NEXT_URL}/pricing?canceled=true`,
metadata: { userId: session.user.id, plan },
})
return NextResponse.json({ url: checkoutSession.url })
}Étape 5 : Déployer sur Vercel
# Installer Vercel CLI
npm i -g vercel
# Déployer
vercel
# Configurer les variables d'environnement
vercel env add DATABASE_URL
vercel env add NEXTAUTH_SECRET
vercel env add STRIPE_SECRET_KEY
# Déployer en production
vercel --prodRécapitulatif des 48 heures
1Heures 0-4 — Setup projet, dépendances, base de données Prisma
2Heures 4-12 — Authentification NextAuth, register, login
3Heures 12-24 — Dashboard, layout, navigation, settings
4Heures 24-36 — Stripe checkout, webhooks, gestion d'abonnement
5Heures 36-44 — Landing page, SEO, emails transactionnels
6Heures 44-48 — Tests, déploiement Vercel, monitoring
Besoin d'un raccourci ?
Le template NeuraSaaS inclut tout ce guide pré-configuré : auth, dashboard, Stripe, landing page, admin panel. Gagnez 40h de développement.
Voir les tarifs →