Build a blog with tRPC, Drizzle, Next.js and Clerk
Blog post from Clerk
The tutorial provides a comprehensive guide to building a blog application using a modern tech stack that includes Next.js, Clerk for authentication, Drizzle as a database ORM, and tRPC for type-safe API endpoints, among others. It begins with setting up a Next.js app integrated with Clerk for user authentication and Drizzle for database management, deploying the app on Vercel, and using Neon for the Postgres database. The tutorial then details how to add tRPC and Zod for enhanced type-safety and schema validation, and how to replace direct database queries with tRPC procedures using Tanstack Query for data fetching and caching. It explores creating protected procedures with Clerk's authentication context to restrict access based on user status. The guide also covers setting up a client component to fetch and display posts and creating a form for users to submit new posts, ensuring security by using server-side user ID retrieval. The tutorial concludes with suggestions for additional features and improvements, such as custom sign-in pages and more user information storage, to enhance the application's functionality before a production release.