Adding custom code
This page covers how to add custom logic, methods, and dependencies to your TypeScript SDK.
.fernignore
file.Adding custom logic
To get started adding custom code:
Custom SDK methods
Fern also allows you to add custom methods to the SDK itself (e.g.
client.my_method()
) by inheriting the Fern generated client and then
extending it.
See an example from Flatfile using this process in their TypeScript SDK
Import and extend the generated client
First, import the Fern generated client from ../client
and alias it to FernClient
.
Next, extend FernClient
and add whatever methods you want.
See an example from Flatfile doing this in their FlatfileClient
Export the extended client
Update your index.ts
file to export the extended client instead of the generated client.
See an example index.ts from Flatfile
Update .fernignore
Add both the wrapper
directory and index.ts
to .fernignore
.
See an example .fernignore from Flatfile
Custom dependencies
To add packages that your custom code requires, update your generators.yml
.