Skip to content


The src/app.ts file is the main file where the Feathers application gets initialized and wired up with a Feathers transport.


The available transports are Koa or Express for HTTP and for real-time functionality. For both, Koa and Express, the Feathers application (app object) will also be fully compatible with the respective framework. For both frameworks, additional required middleware will be registered in the application file. More information can be found in the linked API documentation.

Configure functions

The Feathers application does not use a complicated dependency injection mechanism. Instead, the application is wired together using configure functions to split things up into individual files. They are functions that are exported from a file and that take the Feathers app object and then use it to e.g. register services. Those functions are then passed to app.configure.

For example, have a look at the following files:

src/services/index.ts looks like this:

import type { Application } from '../declarations'
import { user } from './users/users'

export const services = (app: Application) => {
  // All services will be registered here

It uses another configure function exported from src/services/users/users.ts. The export from src/services/index.js is in turn used in src/app.ts as:

// ...
import { services } from './services'

// ...
// ...

This is how the generator splits things up into separate files and any documentation example that uses the app object can be used in a configure function. You can create your own files that export a configure function and require/import and app.configure them.


Keep in mind that the order in which configure functions are called might matter, e.g. if it is using a service, that service has to be registered first. Configure functions are not asynchronous. Any asynchronous operations should be done in application setup hooks.

Application hooks

The application file also includes a section to set up application hooks which are hooks that run for every service. In our case, the logErrorHook to log any service errors has already been registered:

// Register hooks that run on all service methods
  around: {
    all: [logErrorHook]
  before: {},
  after: {},
  error: {}

Following that is the special setup and teardown hook section to register hooks that run once when the application starts or shuts down. This can be used to e.g. set dynamic configuration values.

// Register application setup and teardown hooks here
  setup: [],
  teardown: []

Tests, jobs and SSR

The app file can be imported like any other Node module. This means it can be used directly in tests, scheduled jobs or server side rendering without having to start a separate server instance. For example, the unit tests import the application like this:

import assert from 'assert'
import { app } from '../../src/app'

describe('messages service', () => {
  it('registered the service', () => {
    const service = app.service('messages')

    assert.ok(service, 'Registered the service')

Released under the MIT License.