Server boilerplate


Source code
A starter repo for Express + React, using Fern

Latest version: 0.9.7

The Express generator generates types and networking logic for your Express server. This saves you time and adds compile-time safety by guaranteeing that you are serving the exact API that you specified in your API Definition.

Available on the open source plan.

What Fern generates

  • TypeScript interfaces for your API types
  • Exceptions that you can throw for non-200 responses
  • Interfaces for you to define your business logic
  • All the networking/HTTP logic to call your API

Adding the Express generator

1- name: fernapi/fern-typescript-express
2 version: 0.9.7
3 output:
4 location: local-file-system
5 path: ../generated/server-boilerplate/express

Make sure to enable allowSyntheticDefaultImports in your tsconfig.json when using this generator.

Demo video

Express configurations

The following options are supported when generating an Express backend:


See TypeScript Node.js SDK Configuration options: useBrandedStringAliases.


See TypeScript Node.js SDK Configuration options: treatUnknownAsAny.


See TypeScript Node.js SDK Configuration options: noSerdeLayer.


See TypeScript Node.js SDK Configuration options: outputSourceFiles.


Type: boolean Default: false

By default, the generated register() will require an implementatiion for every service defined in your Fern Definition.

If areImplementationsOptional is enabled, then register() won’t require any implementations. Note that this is mildly dangerous: if you forget to include an implementation, then your server behavior may drift from your docs and clients.


Type: boolean Default: false

By default, if you throw a non-Fern error in your endpoint handler, it will be caught by generated code and a 500 response will be returned. No details from the error will be leaked to the client.

If doNotHandleUnrecognizedErrors is enabled and you throw a non-Fern error, the error will be caught and passed on with next(error). It’s your responsibility to set up error-catching middleware that handles the error and returns a response to the client.


The generated TypeScript code has the following dependencies:

If you are packaging your code manually, make sure to include these dependencies in your package.json.