DEV Community

PubliFlow
PubliFlow

Posted on Edited on

Indie Hacker Stack 2026: Next.js, Supabase, and Creem for SaaS

Indie Hacker Stack 2026: Next.js, Supabase, and Creem for SaaS

If you’ve been building SaaS products for the last few years, you know the pain. You spend the first three weeks just wiring up authentication, configuring payment gateways, and setting up transactional emails. By the time you write your first line of actual business logic, you’re already burnt out.

Welcome to 2026. The indie hacker stack has evolved. We’ve moved past the bloated, legacy monoliths and the fragmented "Frankenstein" stacks of microservices. Today, the modern lean stack for solo founders and small teams is a tightly integrated trio: Next.js (App Router), Supabase, and Creem, supplemented by Resend for email.

When evaluating a saas boilerplate or a nextjs starter kit, the goal isn't just to find a shipfast alternative that gets you to launch; it's to find an architecture that scales without requiring a DevOps team. That’s why I’ve made PubliFlow (https://www.creem.io/payment/prod_74RsEP8aJBd1RT4mRdoP1y) my go-to starter. While most boilerplates stop at auth and payments, PubliFlow is a Next.js SaaS boilerplate that uniquely ships with BUILT-IN multi-platform content publishing (Twitter/X, Reddit, Dev.to, Hashnode), alongside the usual auth, Creem/Stripe payments, and SEO optimizations.

Let’s dive deep into how this stack is wired together, complete with real-world code, architectural patterns, and the pitfalls you need to avoid.

The 2026 Architecture Overview

Before writing code, we need to understand the data flow. Here is the text-based architecture diagram of our stack:

[ Client (React Server Components / Client Components) ]
              │
              ▼
[ Next.js App Router (Edge & Node.js Runtimes) ]
   ├── Server Actions (Mutations)
   └── Route Handlers (Webhooks/API)
              │
  ┌───────────┼───────────┬──────────────┐
  ▼           ▼           ▼              ▼
[Supabase]  [Creem]     [Resend]    [External APIs]
(Auth/DB)  (Payments)   (Email)    (Twitter/Dev.to)
Enter fullscreen mode Exit fullscreen mode

Next.js acts as the orchestration layer. Supabase handles state and identity. Creem acts as the Merchant of Record (MoR), handling global taxes and VAT so you don't have to. Resend handles transactional emails with React Email. And PubliFlow abstracts the marketing distribution.

Deep Dive 1: Supabase Auth and Secure Server Actions

The biggest mistake developers make with Supabase in Next.js is using the Service Role key on the server to bypass Row Level Security (RLS). Don't do this. It defeats the purpose of Supabase's security model. Instead, we pass the user's session to the Supabase client in our Server Actions.

Here is a robust pattern for creating a resource (e.g., a "Project") using Next.js Server Actions and Supabase RLS.

// app/actions/projects.ts
'use server';

import { createSupabaseServerClient } from '@/lib/supabase/server';
import { revalidatePath } from 'next/cache';
import { z } from 'zod';

const CreateProjectSchema = z.object({
  name: z.string().min(3).max(50),
  description: z.string().max(500).optional(),
});

export async function createProjectAction(formData: FormData) {
  // 1. Initialize Supabase client with the user's session cookies
  const supabase = await createSupabaseServerClient();

  // 2. Verify authentication
  const { data: { user }, error: authError } = await supabase.auth.getUser();
  if (authError || !user) {
    return { success: false, error: 'Unauthorized' };
  }

  // 3. Validate input
  const parsed = CreateProjectSchema.safeParse({
    name: formData.get('name'),
    description: formData.get('description'),
  });

  if (!parsed.success) {
    return { success: false, error: 'Invalid input', details: parsed.error.flatten() };
  }

  // 4. Insert data. RLS will automatically filter by user.id if policies are set correctly.
  const { data, error } = await supabase
    .from('projects')
    .insert({
      ...parsed.data,
      owner_id: user.id, // Explicitly setting owner, though RLS should enforce this
    })
    .select()
    .single();

  if (error) {
    console.error('Supabase insert error:', error);
    return { success: false, error: 'Database error' };
  }

  // 5. Revalidate the cache for the dashboard
  revalidatePath('/dashboard/projects');

  return { success: true, data };
}
Enter fullscreen mode Exit fullscreen mode

Why this matters: By using createSupabaseServerClient(), we ensure that the database queries are executed with the permissions of the logged-in user. If your RLS policy says WITH CHECK (auth.uid() = owner_id), this Server Action is cryptographically secure against IDOR (Insecure Direct Object Reference) attacks.

Deep Dive 2: Creem Payments and Webhook Idempotency

For global SaaS, dealing with VAT, GST, and local tax compliance is a nightmare. This is why Creem has become the indie hacker's payment processor of choice. As a Merchant of Record, Creem handles the tax remittance globally.

Integrating Creem requires handling webhooks to provision licenses when a payment succeeds. The most common pitfall here is webhook idempotency. If Creem retries a webhook (or you accidentally process it twice), you might provision two licenses for one payment.

Here is a production-ready Next.js Route Handler for Creem webhooks that ensures idempotency using Supabase.

// app/api/webhooks/creem/route.ts
import { NextRequest, NextResponse } from 'next/server';
import { createSupabaseAdminClient } from '@/lib/supabase/admin';
import { verifyCreemSignature } from '@/lib/creem/webhooks';

export async function POST(req: NextRequest) {
  const payload = await req.text();
  const signature = req.headers.get('x-creem-signature');

  // 1. Verify webhook signature to ensure it's actually from Creem
  if (!verifyCreemSignature(payload, signature)) {
    return NextResponse.json({ error: 'Invalid signature' }, { status: 401 });
  }

  const event = JSON.parse(payload);
  const eventId = event.id;
  const eventType = event.type;

  // 2. Initialize Admin client (bypasses RLS, needed for internal state updates)
  const supabase = createSupabaseAdminClient();

  // 3. Check for idempotency: Have we processed this event ID before?
  const { data: existingEvent } = await supabase
    .from('webhook_events')
    .select('id')
    .eq('event_id', eventId)
    .single();

  if (existingEvent) {
    console.log(`Event ${eventId} already processed. Skipping.`);
    return NextResponse.json({ received: true, duplicate: true });
  }

  // 4. Process the event within a transaction to ensure atomic state changes
  try {
    await supabase.rpc('process_creem_webhook', {
      p_event_id: eventId,
      p_event_type: eventType,
      p_payload: event
    });

    // Note: The above RPC should handle inserting into webhook_events
    // and updating the user's subscription status in a single DB transaction.

  } catch (error) {
    console.error('Failed to process webhook:', error);
    // Return 500 so Creem knows to retry
    return NextResponse.json({ error: 'Processing failed' }, { status: 500 });
  }

  return NextResponse.json({ received: true });
}
Enter fullscreen mode Exit fullscreen mode

Pro-tip: Notice the use of supabase.rpc('process_creem_webhook'). By pushing the idempotency check and the state mutation into a single Postgres function (RPC), you eliminate race conditions. If two webhooks arrive at the exact same millisecond, Postgres will lock the row, ensuring the subscription is only upgraded once.

Deep Dive 3: The Secret Weapon - Multi-Platform Publishing

Building the product is only 20% of the work; marketing is the other 80%. Most saas boilerplate kits leave you to figure out how to distribute your content. This is where PubliFlow (https://www.creem.io/payment/prod_74RsEP8aJBd1RT4mRdoP1y) completely changes the game.

PubliFlow isn't just a wrapper for auth and payments; it includes a native, built-in multi-platform content publishing engine. When you write a blog post, changelog, or marketing update in your CMS, PubliFlow's Server Actions automatically format and push that content to Twitter/X, Reddit, Dev.to, and Hashnode.

Here is a simplified look at how PubliFlow handles a multi-platform publish action under the hood:

// app/actions/publishing.ts (Abstracted from PubliFlow's core)
'use server';

import { createSupabaseServerClient } from '@/lib/supabase/server';
import { publishToDevTo } from '@/lib/publishers/devto';
import { publishToTwitter } from '@/lib/publishers/twitter';
import { publishToHashnode } from '@/lib/publishers/hashnode';

export async function publishArticleAcrossPlatforms(articleId: string) {
  const supabase = await createSupabaseServerClient();
  const { data: article, error } = await supabase
    .from('articles')
    .select('*')
    .eq('id', articleId)
    .single();

  if (error || !article) return { success: false, error: 'Article not found' };

  const results = { devto: null, twitter: null, hashnode: null };

  // 1. Publish to Dev.to (Full markdown article)
  if (article.publish_targets.includes('devto')) {
    results.devto = await publishToDevTo({
      title: article.title,
      bodyMarkdown: article.content_markdown,
      tags: article.tags,
      published: true
    });
  }

  // 2. Publish to Twitter/X (Formatted thread/summary)
  if (article.publish_targets.includes('twitter')) {
    // PubliFlow automatically generates a concise thread from the markdown
    results.twitter = await publishToTwitter({
      text: `🚀 New on the blog: ${article.title}\n\n${article.summary}\n\nRead more: ${article.canonical_url}`
    });
  }

  // 3. Publish to Hashnode (Full markdown with canonical URL)
  if (article.publish_targets.includes('hashnode')) {
    results.hashnode = await publishToHashnode({
      title: article.title,
      contentMarkdown: article.content_markdown,
      tags: article.tags.map(t => ({ name: t })),
      canonicalUrl: article.canonical_url
    });
  }

  // 4. Update local DB status
  await supabase.from('articles').update({
    published_at: new Date(),
    platform_status: results
  }).eq('id', articleId);

  return { success: true, results };
}
Enter fullscreen mode Exit fullscreen mode

This pattern saves hours of manual copy-pasting and context-switching. You write once, and PubliFlow handles the API nuances, rate limits, and formatting for each platform.

Common Pitfalls and How to Avoid Them

Even with a great nextjs starter kit, architecture mistakes can haunt you. Here are the critical pitfalls to avoid in 2026:

1. The "N+1" Query Problem in React Server Components

When fetching relational data in RSC, it's easy to accidentally trigger N+1 queries.

  • Pitfall: Fetching a list of projects, then mapping over them and fetching the user for each project individually.
  • Solution: Use Supabase's !inner or !left joins to fetch relational data in a single query. Alternatively, use DataLoader patterns or batch your requests.

2. Leaking Service Role Keys

  • Pitfall: Using the Supabase Service Role key in your Next.js API routes for convenience. If your server is compromised, the attacker has full god-mode access to your database.
  • Solution: Strictly use RLS. Only use the Service Role key in isolated, highly controlled backend cron jobs or specific webhook handlers where you absolutely must bypass user context.

3. Ignoring Edge vs. Node.js Runtimes

  • Pitfall: Running heavy database queries or Node-specific libraries (like certain PDF generators) on the Edge runtime, causing crashes.
  • Solution: Explicitly define your runtime. Use export const runtime = 'edge'; for fast, globally distributed marketing pages and API routes that don't need Node APIs. Use the default Node runtime for Server Actions that interact heavily with Supabase or file systems.

Performance Considerations

To ensure your SaaS feels instantaneous, leverage Next.js caching strategies alongside Supabase:

  • Data Caching: Use unstable_cache (or the stable equivalent in your Next.js version) for heavy, read-only dashboard widgets. Combine this with Supabase Realtime to invalidate the cache when the underlying data changes.
  • Connection Pooling: Supabase uses Supavisor for connection pooling. Ensure your Next.js app is configured to use the pooled connection string (usually port 6543) rather than the direct connection string (port 5432) to prevent exhausting your database connections during traffic spikes.
  • Image Optimization: Always use the next/image component. If you're storing user avatars or product images in Supabase Storage, serve them through Next.js Image Optimization to automatically convert them to WebP/AVIF and serve the correct sizes.

Key Takeaways

The 2026 indie hacker stack is all about leverage. By combining Next.js App Router for a blazing-fast UI, Supabase for a secure, scalable backend, and Creem for frictionless global payments, you eliminate 90% of the operational overhead.

But the true leverage comes from your tooling. Choosing a comprehensive saas boilerplate like PubliFlow (https://www.creem.io/payment/prod_74RsEP8aJBd1RT4mRdoP1y) means you aren't just getting auth and payments; you're getting a built-in marketing engine that pushes your content to Twitter, Dev.to, and Hashnode automatically. It allows you to focus entirely on product-market fit rather than plumbing.

If you are looking to expand your toolkit, exploring curated resources like ShopVeigo is a great way to find complementary SaaS tools, premium UI templates, and developer utilities that integrate seamlessly with this stack.

Stop wiring up boilerplate. Start shipping your SaaS.

Top comments (0)