1. Examples
  2. Custom Modules

Custom Modules

Use npm packages and third-party libraries in your Zuplo handlers and policies.

Deploy to Zuplo
Deploy to Zuplo

Prerequisite: You need a Zuplo account to run this example. Sign up for free

This sample demonstrates how to bundle custom node modules to use in your Zuplo project. In order to use this in your own Zuplo project, you must connect to source control and clone your project locally.

1/ Install Your Custom Module

First, install your custom module into your project:

Terminalbash
npm install YOUR_MODULE

2/ Bundle the Module

Bundle the module using tsdown. You can use other bundling tools as well, but tsdown is simple and effective for this purpose.

Terminalbash
npx tsdown ./node_modules/YOUR_MODULE --format esm --platform browser --out-dir ./modules/third-party/YOUR_MODULE

For convenience, add this as a script in your package.json:

JSONjson
{
  "scripts": {
    "bundle": "npx tsdown ./node_modules/YOUR_MODULE --format esm --platform browser --out-dir ./modules/third-party/YOUR_MODULE"
  }
}

Then run:

Terminalbash
npm run bundle

3/ Use the Module

Inside of your code you can now import the custom module through the path. One thing to note is that you will not have code completion for this module. See the next step for information on how to include type definitions.

TypeScriptts
import MyModule from "./third-party/my-module";

4/ Optional: Type Definitions

By default this script will not copy or generate any type definition files. This means your custom module will be used as any any object and you wont have code completion.

If you want to bundle the type definitions (*.d.ts) files, we recommend copying them manually to the output directory - i.e. ./modules/third-party/YOUR_MODULE/index.d.ts

Updating the Bundle

If you would like to update your custom module, you will need to first install the new module version. You can install the latest version of a module by running npm install YOUR_MODULE@latest, then re-run the npm run bundle command. This will overwrite the existing bundle with the new version of the module.

Use this example locally

To develop with this example locally, you can create a new Zuplo project using our CLI

Terminalbash
npx create-zuplo-api@latest my-api --example custom-module

Then, in the project directory run the following commands:

Terminalbash
npm install
npm run bundle
npm run dev

Quick Links

View on GitHubDocumentation

Run Locally

Clone and run this example:

npx create-zuplo-api --example custom-module

On This Page

Related Examples

Explore more examples in this category

Idempotency Keys

Programmability

Prevent duplicate API requests and ensure safe retries for payments and critical operations.

View Example

Custom Rate Limiting

Programmability

Customize the error response users see when they hit your API rate limits.

View Example

Dynamic Rate Limits

Programmability

Set different rate limits based on user subscription tier or API key metadata.

View Example

Log Request & Response

Programmability

Debug API issues by capturing full request and response bodies in your logs.

View Example
Check all of our Examples

Scale your APIs with
confidence.

Start for free or book a demo with our team.
Book a demoStart for Free
SOC 2 TYPE 2High Performer Spring 2025Momentum Leader Spring 2025Best Estimated ROI Spring 2025Easiest To Use Spring 2025Fastest Implementation Spring 2025

Get Updates From Zuplo

Zuplo logo
© 2026 zuplo. All rights reserved.
Products & Features
API ManagementAI GatewayMCP ServersMCP GatewayDeveloper PortalRate LimitingOpenAPI NativeGitOpsProgrammableAPI Key ManagementMulti-cloudAPI GovernanceMonetizationSelf-Serve DevX
Developers
DocumentationBlogLearning CenterCommunityChangelogIntegrations
Product
PricingSupportSign InCustomer Stories
Company
About UsMedia KitCareersStatusTrust & Compliance
Privacy PolicySecurity PoliciesTerms of ServiceTrust & Compliance
Docs
Pricing
Sign Up
Login
ContactBook a demoFAQ
Zuplo logo
DocsPricingSign Up
Login