Why do so many developers still rely on REST APIs when full-stack TypeScript with tRPC offers end-to-end type safety out of the box? I recently used vibe coding to prototype a small app, and the seamless type-sharing between server and client blew me away. No duplicated types, no runtime type errors, just pure TypeScript confidence throughout the stack. Here’s how simple it can be: ```typescript // server/router.ts import { initTRPC } from '@trpc/server' const t = initTRPC.create() export const appRouter = t.router({ greet: t.procedure .input(({ name }: { name: string }) => name) .query(({ input }) => `Hello, ${input}!`), }) export type AppRouter = typeof appRouter // client.ts import { createTRPCProxyClient, httpBatchLink } from '@trpc/client' import type { AppRouter } from './server/router' const client = createTRPCProxyClient<AppRouter>({ links: [httpBatchLink({ url: '/trpc' })], }) async function sayHello() { const greeting = await client.greet.query('TypeScript') console.log(greeting) // "Hello, TypeScript!" } sayHello() ``` No need to write OpenAPI specs or generate client SDKs. When I tweak my backend types, the client instantly picks up the change, reducing integration bugs drastically. This workflow has saved me hours and prevented those frustrating “but it worked yesterday” moments. Has anyone else embraced full-stack TypeScript with tRPC? What challenges did you face moving away from REST or GraphQL? #WebDevelopment #TypeScript #Frontend #JavaScript
TypeScript with tRPC: End-to-End Type Safety for Full-Stack Development
More Relevant Posts
-
Unpopular opinion: If you're still building internal API routes in Next.js 16, you're doing it wrong. Writing fetch('/api/user') is officially a legacy pattern. I know that sounds a bit aggressive. We’ve spent the last decade religiously building REST endpoints for everything, so it feels incredibly weird to let that muscle memory go. But once you actually embrace Server Functions, going back to the /api directory feels like coding in the dark. Think about the traditional workflow for a second: → You build an endpoint → You write a fetch call → You manually type the response on the frontend → You cross your fingers and hope your frontend types actually match the backend Oh, and don't forget the massive overhead of maintaining internal API documentation just so your own team knows what endpoints to hit. Next.js 16 completely eliminates this busywork. 🚀 By using Server Functions, you literally just import your backend code like a standard JavaScript function. Instead of writing out a fetch call and parsing JSON, you just write: const user = await getUser() The real magic here isn't just saving a few lines of boilerplate. It's the end-to-end type safety. Your frontend knows exactly what that function returns because TypeScript is enforcing the contract directly. If you change a database field on the server, your frontend build breaks immediately in your IDE. No more runtime surprises. No more internal Swagger docs. The code itself is the contract. 🤝 And from a security standpoint? The 'use server' directive handles the network boundary for you, creating a secure, hidden POST endpoint under the hood without exposing your internal logic. Now, let me be clear—API routes aren't totally dead. You absolutely still need traditional endpoints for: • Public APIs for external clients • Handling third-party webhooks • Serving a separate mobile app But for your own internal app logic? The days of writing fetch boilerplate are over. Have you started migrating your internal logic to Server Functions yet, or are you still holding onto the /api folder? 👇 #Nextjs #WebDevelopment #TypeScript
To view or add a comment, sign in
-
When building APIs with Node.js and Express.js, the way you call APIs can significantly impact performance. A common mistake many developers make is calling APIs one by one (sequentially) when the requests are independent. 1️⃣ Sequential API Calls (One by One) In this approach, each API waits for the previous one to complete. JavaScript const user = await getUser(); const orders = await getOrders(); const payments = await getPayments(); Here, every request blocks the next one. If each API takes 500ms, the total time becomes: 500ms + 500ms + 500ms = 1500ms This increases response time and slows down your backend. 2️⃣ Parallel API Calls (All at Once) If the APIs are independent, you can run them in parallel using Promise.all(). JavaScript const [user, orders, payments] = await Promise.all([ getUser(), getOrders(), getPayments() ]); Now all requests run simultaneously, so the total time becomes roughly: ~500ms instead of 1500ms Why this matters Optimizing API calls can dramatically improve: • Backend performance • API response time • User experience • Server efficiency Simple Rule Use sequential calls only when one API depends on another. Otherwise, use parallel execution with Promise.all(). Small backend optimizations like this can make a huge difference at scale. #NodeJS #ExpressJS #BackendDevelopment #JavaScript #API #WebDevelopment #SoftwareEngineering
To view or add a comment, sign in
-
-
"The future of scalable apps is Full-stack TypeScript with tRPC. Most teams aren't ready for it. 1. **Embrace Type Safety**: Use TypeScript for both front-end and back-end. This ensures that your contract between server and client isn’t just assumed; it’s guaranteed. 2. **Implement tRPC**: Build your API without schemas. tRPC provides end-to-end type safety by deriving types directly from your TypeScript code, a game changer for reducing errors. 3. **Skip REST and GraphQL Complexity**: Avoid manual type definitions and boilerplate. tRPC simplifies communication with fewer dependencies, making your stack more maintainable. 4. **Accelerate Development**: Try AI-assisted tooling to boost coding speed. It's perfect for rapidly prototyping with 'vibe coding' in TypeScript, letting you focus on logic rather than setup. 5. **Enhance Collaboration**: Share types across your team to eliminate the disconnect between front-end and back-end developers. This leads to fewer bugs and faster feature delivery. 6. **Debug Effortlessly**: With consistent types across your stack, trace issues in minutes, not hours. Your IDE becomes a powerhouse for preventing runtime errors with type hints. 7. **Stay Current**: Build on the latest versions of Node.js and TypeScript to leverage modern syntax and features. This keeps your tech stack up-to-date and efficient. ```typescript import { initTRPC } from '@trpc/server'; const t = initTRPC.create(); const appRouter = t.router({ getUser: t.procedure .input((val: unknown) => /* input validation */) .query(({ input }) => { return { id: input, name: "John Doe" }; // Example response }), }); ``` What challenges are you facing with full-stack TypeScript and tRPC integration?" #WebDevelopment #TypeScript #Frontend #JavaScript
To view or add a comment, sign in
-
-
Sometimes the best developer tools come from solving our own frustrations. Every new Node.js project starts the same: routine setup and installing dependencies from scratch. By the time the setup is finished, I still haven’t written any real application logic. After repeating this process over and over again, I asked myself: “Why not automate the start of the project itself?” So I built node-init-app ⚡ A CLI tool that creates a production-ready Node.js backend in under 10 seconds. Run: npx node-init-app my-app ✨ Includes: • Controllers / Models / Routes / Services structure • JWT Authentication (Login/Register + protected routes) • Dev / Staging / Production environment setup • JavaScript or TypeScript option No boilerplate. Just start building. https://lnkd.in/g99JiQRG Give it a try, share your feedback, and let me know what features you'd like to see next. We'll keep improving and releasing new versions. Special thanks to Karthick Thangavelu for the guidance and encouragement during the development and publishing of this package. Your mentorship helped turn a small frustration into a published tool! 🙌 #NodeJS #NPM #JavaScript #TypeScript #OpenSource #DeveloperTool:
To view or add a comment, sign in
-
-
🚀 Express.js isn’t just a framework… it’s the backbone of modern Node APIs Most developers use Express… But only a few truly understand its power. Let’s break it down 👇 💡 What makes Express.js so powerful? 👉 Minimal, fast, and unopinionated 👉 Built on top of Node.js (V8 engine ⚡) 👉 Perfect for REST APIs & microservices 👉 Huge ecosystem of middleware ⚙️ The magic lies in Middleware Every request flows like this: Request → Middleware → Middleware → Route → Response ✔ Authentication ✔ Logging ✔ Validation ✔ Error handling 👉 You control everything. 🧠 Simple Example const express = require('express'); const app = express(); app.use(express.json()); app.get('/api/users', (req, res) => { res.json({ message: 'Users fetched successfully 🚀' }); }); app.listen(3000, () => console.log('Server running on port 3000')); 🔥 Why developers love Express ✔ Easy to learn ✔ Scales from small apps → large systems ✔ Works perfectly with TypeScript ✔ Massive community support ⚠️ But here’s the truth most ignore Express is minimal by design. 👉 No structure 👉 No strict rules That means: ❌ Bad architecture = messy code ✅ Good architecture = production-ready APIs 💬 Pro Tip If you're serious about backend: 👉 Use MVC or Clean Architecture 👉 Add validation (Joi / Zod) 👉 Handle errors globally 👉 Never skip middleware design 💥 Final Thought Express doesn’t make you a great backend developer… 👉 How you structure it does. 🔥 Follow for more: Node.js | Express | System Design | Real-world APIs #NodeJS #ExpressJS #BackendDevelopment #WebDevelopment #JavaScript #APIs #SoftwareEngineering
To view or add a comment, sign in
-
-
IT TOOK ME 2 MONTHS I built a tool that eliminates one of the most repetitive parts of backend development. Introducing: Visual API Orchestrator It lets you: • Design your database visually • Generate Prisma schema instantly • Create full CRUD APIs automatically • Export a complete backend project (ready to run) No more writing boilerplate for every project. What used to take hours now takes minutes. Tech stack: React + TypeScript Node.js + Express Prisma + SQLite This is a production-grade MVP focused on developer productivity. I’d love your feedback. #buildinpublic #webdevelopment #javascript #react #nodejs #prisma
To view or add a comment, sign in
-
Hey everyone! I just discovered an amazing new tool that every TypeScript developer should try – it’s called create-better-t-stack (v3.26.0)! It’s a modern CLI that lets you scaffold end-to-end type-safe TypeScript projects in minutes, following best practices and giving you a super clean project structure. What I love about it: 💻 TypeScript everywhere – full type safety across frontend, backend, and APIs. ⚡ Flexible frontend options – React, Next.js, SvelteKit, Nuxt, SolidJS, Astro, React Native… you name it. 🔧 Backend options – Hono, Express, Fastify, Elysia, Convex, or even self-hosted fullstack. 📦 Databases & ORM – SQLite, PostgreSQL, MySQL, MongoDB with Prisma, Drizzle, or Mongoose. ✨ Awesome addons – PWA support, Tauri for desktop apps, documentation tools, linting & formatting, Git hooks, AI agents… the list goes on! 🛠 Developer-friendly – automatic Git init, choice of package manager (npm, pnpm, bun), and automatic dependency installation. Quick Start is super easy: # Using Bun (recommended) bun create better-t-stack@latest # Using pnpm pnpm create better-t-stack@latest # Using npm npx create-better-t-stack@latest Just follow the prompts and you’re ready to go! ⚡ Whether you want a full Fullstack project, frontend-only, or just a minimal API, this tool makes your life so much easier. Check it out here: create-better-t-stack on npm If you love TypeScript and want to save hours of setup time, you have to try this! 🙌 #TypeScript #Fullstack #WebDevelopment #React #NextJS #DevTools #OpenSource #Frontend #Backend #DeveloperExperience
To view or add a comment, sign in
-
-
I built API Hook Builder — a tool that converts any JSON API endpoint into production-ready React hooks and TypeScript types in seconds. Paste an API URL → instantly get: • Fully typed TypeScript interfaces (including nested objects & arrays) • A fetch wrapper ready for production • A TanStack React Query hook you can drop directly into your project No CLI. No signup. No backend processing. Everything runs 100% in your browser — which means your API data never leaves your machine. The idea is simple: developers shouldn't waste time writing repetitive boilerplate when the structure already exists in the API response. So the tool: 1.Fetches the JSON response 2.Recursively analyzes the schema 3.Generates clean TypeScript interfaces 4.Builds a ready-to-use React Query hook Built with React + Vite + TypeScript + Tailwind + shadcn/ui. If you work with APIs in React, this can save you a ridiculous amount of setup time. Try it here Live: https://lnkd.in/gN3gsT-7 GitHub: https://lnkd.in/gZhDSx39 Would love to hear feedback from other devs. #webdevelopment #reactjs #typescript #frontenddevelopment #javascript #devtools #buildinpublic #indiehacker #opensource #developertools #api #softwareengineering #codinglife #reactquery
To view or add a comment, sign in
-
Recently I worked on an API optimization issue where multiple independent async operations were being executed sequentially inside a backend flow. Earlier, the API was calling each async function one by one: const users = await getUsers(); const posts = await getPosts(); const comments = await getComments(); In this approach, each request waits until the previous one finishes. Example timing: - getUsers() → 300ms - getPosts() → 400ms - getComments() → 500ms Total response time ≈ 1200ms Since these operations were independent, I optimized the flow using Promise.all(): const [users, posts, comments] = await Promise.all([ getUsers(), getPosts(), getComments() ]); Now all requests run in parallel. Optimized timing: All three complete together based on the slowest request. Total response time ≈ 500ms Result: ✅ Around 50–60% faster response time ✅ Reduced API waiting time ✅ Better scalability under load ✅ Improved end-user experience This reminded me that performance improvement often comes from changing execution strategy, not only writing more code. Small optimization decisions can create a strong impact in production systems 🚀 #API #NodeJS #JavaScript #Backend #PerformanceOptimization #WebDevelopment #Learning
To view or add a comment, sign in
-
🚀 Node.js Performance Tip Most Developers Still Ignore If your API feels slow, there’s a high chance you’re making this common mistake 👇 ❌ Sequential API Calls Running async operations one by one increases total response time unnecessarily. const user = await getUser(); const orders = await getOrders(); const payments = await getPayments(); ⏱️ If each call takes 100ms → Total = 300ms ⸻ ✅ Optimized Approach: Promise.all() const [user, orders, payments] = await Promise.all([ getUser(), getOrders(), getPayments() ]); ⚡ Now all requests run in parallel ⏱️ Total time ≈ 100ms ⸻ 💡 Key Rule: If your API calls are independent, NEVER run them sequentially. ⚠️ Use Promise.all() only when: ✔️ No dependency between requests ✔️ You can handle failures properly ⸻ 🔥 Why this matters: • Faster APIs = Better user experience • Better performance = Higher scalability • Small optimization = Big impact ⸻ 💬 Want more backend performance tips like this? Comment “MORE” 👇 #NodeJS #JavaScript #BackendDevelopment #WebPerformance #FullStackDeveloper #SoftwareEngineering #APIDevelopment #CodingTips #Developers #TechTips #MERNStack #PerformanceOptimization
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development