Podcast Summary
An alternative to REST and GraphQL for building APIs using functions and TypeScript: Developers define functions, tRPC infers API specification, and HTTP GET and POST are used for queries and mutations, simplifying API development and handling client-side caching automatically
TRPC is an alternative to REST and GraphQL for building APIs. Instead of focusing on endpoints and APIs, developers express their entire back end as functions and use TypeScript to infer the API specification. Queries and mutations are called over HTTP GET and POST, respectively, allowing for easy caching at the HTTP layer. With the React client for tRPC, which is built on top of React Query, client-side caching is handled automatically. Essentially, developers define functions and behind the scenes, these functions make fetch calls. This approach simplifies API development by eliminating the need for schema definitions and generating client-side caches. Companies like Polypane, Fire Hydrant, and Kentico are already using tRPC to build better websites, incident management systems, and headless CMSs.
Streamlined Type-Safe APIs with tRPC: TRPC allows for end-to-end type safety and auto-completion between client and server in a TypeScript project, eliminating the need for separate GraphQL servers or clients, and improving developer productivity through code navigation and type checking.
TRPC provides end-to-end type safety and auto-completion between the client and server in a TypeScript project, without the need for a separate GraphQL server or client. The client and server both define their types, and the client imports the server's types, giving it compiled-time information for type checking and code navigation. This setup avoids the need to export runtime types or deal with crossover between client and server environments. TypeScript's powerful type inference system infers the types of variables and functions, allowing for seamless type checking and renaming across the application. Overall, tRPC offers a more streamlined approach to building type-safe APIs, with the added benefit of improved developer productivity through code navigation and type checking.
Improve development experience with TypeScript, tRPC, XOD, and Polypane: Using TypeScript with tools like tRPC and input validation libraries such as XOD, along with Polypane, can streamline development by providing static typing, improved business logic handling, better tooling, and responsive testing.
Using TypeScript with tools like tRPC and input validation libraries such as XOD can greatly enhance the developer experience by providing static typing, improved business logic handling, and better tooling for testing and debugging. Polypane, a browser with power tools for working on the web, is an excellent companion for this setup. It offers multiple panes for responsive testing, accessibility tools, SEO tools, and web quality checks. Polypane keeps all panes in sync, enabling developers to see the impact of changes across different devices and sizes without repetition. Additionally, Polypane provides access to dev tools and offers a free 14-day trial with a 20% discount using the code "syntax20." While XOD is an excellent input validation library for TypeScript, it's not a requirement for using tRPC, as other libraries like Yap and Deepgram are also compatible. XOD's creator, Colin, was also instrumental in the initial development of tRPC. The combination of TypeScript, tRPC, and XOD, along with tools like Polypane, can lead to a more efficient, effective, and enjoyable development experience.
Using XOD for TypeScript-centric schema validation: XOD offers optional types by default, making it a powerful and convenient choice for TypeScript developers for schema validation. It keeps everything in one language when working with TypeScript clients.
XOD is a TypeScript-centric schema validation library that offers optional types by default, making it more aligned with TypeScript's type system. This contrasts with other libraries where you have to explicitly define optional types. XOD's optional types and its growing community make it a powerful and convenient choice for schema validation. The speaker, who has been using it for validation in their back end, appreciates this feature and the fact that it keeps everything in one language when working with TypeScript clients. When it comes to tRPC, it's important to note that it was created after the speaker's extensive experience with GraphQL. While there are similarities in concepts, tRPC is designed specifically for TypeScript, eliminating the need for extra cogeneration steps when working with clients in other languages. Although GraphQL offers more advanced features like a normalized cache, tRPC is simpler and faster, as it doesn't require discussions about API contracts or how data should be structured. However, it's worth mentioning that GraphQL's extensive feature set comes at a cost, requiring a good understanding of how the graph model works.
Understanding the differences between GraphQL and tRPC: GraphQL and tRPC serve similar purposes but have distinct approaches. GraphQL offers a schema for data relationships and can lead to the 'n+1' problem, while tRPC does not have a schema and requires manual data loading. Both have their advantages and disadvantages, and understanding the differences is crucial for choosing the right tool for your project.
While both GraphQL and tRPC are used for fetching data from a server to a client, they have distinct approaches and use cases. GraphQL allows for defining a schema to relate data and can lead to the "n+1" problem, where multiple database queries are required to fetch related data. tRPC, on the other hand, does not have any relationship between entities in the back end and requires developers to handle database queries and data loading themselves. The lack of a schema system in tRPC can be an advantage for smaller teams or projects where full-stack development is desired, but it also introduces an area of potential issues that need to be handled manually. It's essential to understand the differences and choose the right tool based on the specific needs and constraints of your project. Additionally, implementing proper authorization and authentication is crucial for securing your GraphQL or tRPC API. Furthermore, the discussion touched upon Fire Hydrant, an incident management platform that simplifies the process of resolving incidents, communicating with stakeholders, and learning from incidents. It offers out-of-the-box automations, a service catalog, and retrospectives, making it an invaluable tool for engineering teams looking to improve their incident response and post-incident analysis processes.
Modern API framework with typed APIs for client and server communication: TRPC is a modern framework that provides typed APIs for both client and server communication, enabling automatic batching and eliminating manual query synchronization. It's framework-agnostic and comes with specialized adapters for React, Next.js, and other popular frameworks.
TRPC is a modern API framework that provides typed APIs for both client and server communication. It allows for automatic batching of requests, eliminating the need for manual synchronization of query names. tRPC is framework-agnostic and can be used with various environments like Deno, Bun, and Node.js. It comes with specialized adapters for React and Next.js, offering features like automatic server-side rendering and server-side props helpers. The community also supports adapters for other frameworks like Vue, Nuxt, and Svelte. As the creator of this framework, it's a rewarding experience to see people adopt and contribute to the project, creating new community-driven adapters.
Community support drives the success of tRPC: The project tRPC, which combines TypeScript and GraphQL benefits without complexities, has seen significant growth through word-of-mouth and community contributions, with 90,000 weekly downloads on NPM and increasing GitHub stars.
The organic growth and support from the community have been key factors in the success of the project, tRPC. The creator was surprised and grateful for the intricate contributions from individuals he had never interacted with before. The project, which offers benefits of both TypeScript and GraphQL without their extra complexities, has seen significant growth through word-of-mouth. With approximately 90,000 weekly downloads on NPM and a continuously increasing number of GitHub stars, the project has gained traction in the community. Content by Kentico, a sponsor of this episode, was also discussed as a headless CMS with a user-friendly content calendar and interface, making it an effective tool for managing and organizing content.
Content.ai's advanced features and extended trial offer: Content.ai provides a headless CMS solution with advanced features including real human support, automatic redirects, team-based tasks and to-dos, live editing, and support for both REST and GraphQL APIs. They are currently offering an extended 3-month trial instead of the usual 1-month trial.
Content.ai offers a headless CMS solution with advanced features such as real human support for technical issues, automatic redirects, team-based tasks and to-dos, live editing, and support for both REST and GraphQL APIs. The user interface and tools are next level, and Content.ai is currently offering an extended 3-month trial instead of the usual 1-month trial. In the future, tRPC, a project sponsored by Content.ai, plans to release version 10 with improved developer experience and TypeScript performance, and explore the possibility of binary transports as an alternative to JSON for situations where it becomes too bloated. TypeScript, which Content.ai heavily relies on, can be challenging to work with due to its heavy reliance on inference, a feature that makes the language so powerful but can impact performance. To improve the performance of tRPC, the team had to reconsider their approach and find ways to optimize the codebase. TypeScript crashes and the need for frequent restarts can be frustrating, but the benefits of using inference make it a more than worthwhile investment. Content.ai's commitment to providing a superior user experience and advanced features sets it apart from other CMS solutions.
Combining trial and error and performance tracing tools for optimal TypeScript backend performance: TypeScript's nonlinear complexity in handling procedures and routers can slow down large backend projects, but tRPC's logic and JavaScript foundation can scale infinitely. Use trial and error and performance tracing tools for best results, while enjoying custom error codes and client-side error handling.
TypeScript's nonlinear complexity in handling procedures and routers can lead to slow feedback in large backend projects. The best solution, according to the speaker, is a combination of trial and error and using performance tracing tools. However, the logic and JavaScript underlying tRPC can scale infinitely, making it a powerful choice. tRPC also borrows concepts from GraphQL, such as custom error codes that map to proper HTTP error codes, allowing for full control and browser standards. The ability to throw and handle tRPC errors with custom shapes in the client is a standout feature. The speaker's inspiration for building tRPC was a combination of necessity and borrowing ideas, with a focus on creating a tool that offers the best of both worlds in terms of control and standards. If you're looking to pick up tRPC, the speaker encourages checking out the documentation.
Exploring the Best of Both Worlds with tRPC: The speaker is updating his codebase with tRPC to leverage modern APIs and front-end experiences while maintaining the simplicity and productivity of PHP and the LAMP stack.
The speaker values the simplicity and productivity of working with PHP and the LAMP stack, but recognizes the importance of modern APIs and front-end experiences. He is currently making changes to his codebase to combine the best of both worlds using tRPC, which not only handles type safety between the front and back end but also offers a flexible middleware structure for creating complex back ends in a declarative way. The speaker also mentioned that tRPC is more than just a way to infer types between the front and back end and that its advanced middleware structure is worth exploring. In terms of personal preferences, the speaker uses an M1 Air laptop and is considering getting a split ergonomic keyboard for better posture. He uses the standard dark font and theme in Visual Studio Code and has never been particularly interested in customizing his text editor settings.
Exploring coding tools: A personal journey: Start small with a passion project, find what works best for you, and stay updated through platforms like Twitter. Enjoy the process and don't get too fixated on specific tools or technologies.
Finding the right tools and environment for coding can be a personal journey, and starting small with a passion project is more important than getting bogged down in the latest trends or tech stacks. The speaker shared his experiences of starting out in coding through IRC rooms and using various tools, and emphasized the importance of finding what works best for an individual. He also mentioned staying updated through platforms like Twitter and being excited about the potential of WebAssembly (WASM) in the future of web development. The speaker didn't have a specific "sick pick" to share, but encouraged exploring different options and finding what fits best. The key is to enjoy the process and not get too fixated on specific tools or technologies.
Discovering TypeSafe SQL Query Building with Case Celie: Learn about Case Celie, a TypeScript-friendly SQL query builder, and how it offers type safety without much additional work. Also, follow @alex.js for updates on new tools and technologies.
Alex was discussing the use of Case Celie, a TypeScript-friendly SQL query builder inspired by KneX, which offers type safety without much additional work. This was a new discovery for him and he was excited to share it with the audience. He also mentioned his Twitter handle, @alex.js, and shared a personal anecdote about how he strives to secure short and desirable usernames in various online communities. The conversation also touched upon TRPC, a new technology that Alex believes will open many people's eyes and provide a better understanding of its implementation. Overall, the discussion provided valuable insights into new tools and technologies that can enhance productivity and development experience for developers.