Marketplace Starter Kit

FAQs & Troubleshooting

Common questions and issues when using Supabase, Prisma, tRPC, and Next.js in this app.

Common Questions & Issues


Prisma Connection Errors

Problem: Prisma can throw errors like:

  • prepared statement already exists
  • Can't reach database server at ...
  • Timed out fetching a new connection from the connection pool

Solution:

  1. Append ?pgbouncer=true to your Supabase pooling DATABASE_URL to disable problematic prepared statements.
  2. Increase timeouts as needed:
    DATABASE_URL="...pgbouncer=true&connect_timeout=30&pool_timeout=30"
  3. Monitor your DB connection limits—optimize slow queries and scale your Supabase instance if needed.

PrismaClient in Browser / Edge Runtime

Issue: Running PrismaClient in the browser or edge runtime causes errors.

Recommendation:

  • Only instantiate PrismaClient in back-end or server-side code.
  • Avoid using Prisma APIs in app components with 'use client'.
  • Use tRPC back-end procedures to safely expose data.

Supabase Auth Issues

Problem: Users aren’t being created in your User Prisma model after signup.

Fix:

  • Use Supabase triggers to sync auth users into your public schema.

    CREATE FUNCTION handle_new_user() RETURNS trigger AS $$
    BEGIN
      INSERT INTO public."User"(id) VALUES (NEW.id);
      RETURN NEW;
    END;
    $$ LANGUAGE plpgsql;
    
    CREATE TRIGGER sync_user
      AFTER INSERT ON auth.users
      FOR EACH ROW EXECUTE FUNCTION handle_new_user();
  • Ensure your Prisma User model matches this shape.


tRPC Debugging: Why am I getting any everywhere?

Solution:

  • Enable "strict": true in tsconfig.json.
  • Ensure your @trpc/* versions are aligned.
  • Add this in .vscode/settings.json to use the workspace TypeScript:
    {
      "typescript.tsdk": "node_modules/typescript/lib",
      "typescript.enablePromptUseWorkspaceTsdk": true
    }

Performance: Over-reliance on use client

Issue: Too many client-side data fetches slow down SSR and increase bundle sizes.

Tip:

  • Fetch data in server components or via getServerSideProps, then pass it to client components via initialData.
  • Use .createCaller() on the server to pre-populate data and reduce client JS.

tRPC vs Next.js Server Actions

Question: Should I use tRPC or Next.js Server Actions?

Insight:

  • tRPC provides type-safe client-server APIs ideal for monolithic TypeScript apps.
  • Next.js Server Actions are simpler but don’t offer the same level of type inference or ecosystem support.
  • For your marketplace, tRPC offers more benefits and flexibility.

Still Stuck?

Feel free to:

  • Re-read sections: Database, API (tRPC), or Authentication
  • Open an issue in your project repo
  • Join Supabase / tRPC Discord communities for support