Adding custom code

Fern-generated SDKs are designed to be extended with custom logic, methods, and dependencies. If you want your SDK to do more than just make basic API calls (like combining multiple calls, processing data, adding utilities), you can add custom code that lives in harmony with the generated code.

You can also add custom methods by inheriting the Fern generated client and extending it, plus add any dependencies that your custom methods depend on in your generators.yml file.

Using .fernignore to preserve your customizations

Once you add files containing custom code, use .fernignore to protect your custom code from being overwritten when Fern regenerates your SDK.

Simply add your custom files to the SDK repository and list them in .fernignore. Fern won’t override any files listed there. A .fernignore file is automatically created in your SDK repository when you use GitHub publishing.

Your .fernignore file might look something like this:

.fernignore
1# Documentation and licensing
2README.md
3LICENSE
4
5# Custom workflows
6.github/workflows/test.yml
7.github/workflows/ci.yml
8
9# Custom code
10src/CustomClient.ts
For another example, see Cohere’s .fernignore file for their TypeScript SDK.

You’ll have a separate .fernignore file for each of your SDKs:

├─ company-repo # Top-level repo for all SDKs
├─ fern/
├─ apis/
├─ sdks/
└── generators.yml # Contains settings for all SDKs
├─ typescript-sdk-repo # Repository for a TypeScript SDK
├─ .github/workflows/
├─ src/
└── .fernignore
├─ python-sdk-repo
├─ .github/workflows/
├─ src/
└── .fernignore

Augmenting your SDK with custom code

Get started adding custom code to a specific SDK:

TypeScript logo
TypeScript
Python
Go
Java
.NET

Coming soon

PHP

Coming soon

Ruby

Coming soon