Tutorials

How to Connect Your Codebase to Retool Using Retool RPC

OTC Team··5 min read
How to Connect Your Codebase to Retool Using Retool RPC

If you've ever wanted to call your own backend logic directly from a Retool app without standing up a REST endpoint just for Retool's sake, Retool RPC is exactly what you're looking for. The feature — currently in beta — lets you connect your own codebase to Retool by defining functions in your backend and invoking them from Retool apps and Retool workflows. This guide walks you through what Retool RPC is, how to get started, and how to fix the most common issues (including the notorious ESBuild import error) so you're not stuck at 11pm staring at a broken deployment.

What Is Retool RPC and Why Does It Matter?

RPC stands for Remote Procedure Call. Retool's implementation lets you register functions in your Node.js (or soon, Python) backend using the retoolrpc SDK, and then call those functions like any other query inside your Retool apps. Think of it as a direct bridge between your existing codebase and your Retool frontend — without needing to build and maintain a dedicated internal API layer just for Retool to consume.

This is a big deal for teams that already have business logic living in their backend services. Instead of duplicating that logic or exposing new HTTP endpoints, you register your functions once with the Retool RPC SDK and they become callable from anywhere inside Retool. It's a much cleaner developer experience for internal tooling.

How to Get Started with Retool RPC (Node.js)

Retool RPC currently supports Node.js, with Python support coming soon. Here's how to get up and running:

  • Install the SDK in your Node.js project: npm install retoolrpc
  • Import and initialize the client in your backend using your Retool API credentials.
  • Define the functions you want to expose to Retool using the SDK's registration methods.
  • Start the RPC server so Retool can reach it — this can run as a long-lived process alongside your existing backend.
  • In your Retool app or workflow, add a new query of type Retool RPC, select your registered function, and pass in any required arguments.
  • Run the query — Retool will invoke the function on your backend and return the result in real time.

For a full walkthrough with screenshots, Retool's official quickstart lives at retool.com/docs/retool-rpc-quickstart. You'll also need to fill out the beta enrollment form to have the feature enabled on your Retool instance before the query type becomes available.

Fixing the "Named Export 'RetoolRPC' Not Found" Error

One of the most common issues reported during the beta is a runtime error when deploying to production with TypeScript and ESBuild. The error looks like this:

SyntaxError: Named export 'RetoolRPC' not found in module 'retoolrpc'

This is a module format mismatch. It comes up specifically when ESBuild is configured to output ESM format (--format=esm), which conflicts with how the retoolrpc package is currently bundled. Here are your two fixes, in order of preference:

  • Upgrade to v0.1.3 or later: The Retool team pushed a fix in retoolrpc@0.1.3 that resolves the import issue with ESBuild. Run npm install retoolrpc@latest and redeploy.
  • Switch ESBuild output to CommonJS: If you can't upgrade immediately, change your ESBuild target to --format=cjs instead of --format=esm. This resolves the named export mismatch at the bundler level.
  • Use CommonJS require syntax as a fallback: If you're not using a bundler and still hitting the error, swap your import for the CommonJS equivalent: var rt = require('retoolrpc'); const rpc = new rt.RetoolRPC({ ... })

The root cause is that ESBuild's ESM output doesn't play nicely with certain CommonJS packages that use non-standard export patterns. The retoolrpc v0.1.3 patch addresses this directly, so upgrading is the cleanest long-term path.

Python and Other Language SDKs: What's Coming

At the time of the beta announcement, only the Node.js SDK is available. Retool has confirmed that Python support is coming soon, and the docs hint at additional language SDKs on the roadmap. If your backend is primarily Python-based, watch the tryretool/retoolrpc GitHub repository for new releases — that's where the Python SDK will land first.

When Should You Use Retool RPC vs. a REST Resource?

Retool already supports REST API resources, so it's worth knowing when RPC is the better choice. Use Retool RPC when:

  • Your business logic already lives in a backend service and you don't want to expose new HTTP endpoints just for Retool.
  • You want strongly typed function signatures rather than raw HTTP requests with manually constructed bodies and headers.
  • You're building Retool workflows that need to orchestrate complex backend logic without intermediate API glue code.
  • Your team prioritizes developer experience and wants backend-owned functions to be first-class citizens in Retool.

If you're connecting to a third-party service or a public API, a standard REST or GraphQL resource is still the right tool. But for your own internal backend? Retool RPC is the cleaner path.

How to Enroll in the Retool RPC Beta

Retool RPC is not enabled by default — you need to request access. Fill out the beta enrollment form linked from the Retool RPC quickstart docs page. Once approved, the Retool RPC query type will appear in your Retool app and workflow editors. If you're already on a self-hosted Retool instance, make sure your instance can reach the host where your RPC server is running.

Retool RPC is one of the more developer-friendly features Retool has shipped in a while. Once the Python SDK drops and the ESBuild issues are fully ironed out, it's likely to become the standard way teams with real engineering backends connect their code to their internal tools.

Ready to build?

We scope, design, and ship your Retool app — fast.

Ready to ship your first tool?