View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

Extending Sails

In keeping with the Node philosophy, Sails aims to keep its core as small as possible, delegating all but the most critical functions to separate modules*. There are currently three types of extensions that you can make to Sails:

  • Generators - for adding and overriding functionality in the Sails CLI. Example: sails-generate-model, which allows you to create models on the command line with sails generate model foo.
  • Adapters - for integrating Waterline (Sails' ORM) with new data sources, including databases, APIs, or even hardware. Example: sails-postgresql, the official PostgreSQL adapter for Sails.
  • Hooks - for overriding or injecting new functionality in the Sails runtime. Example: sails-hook-autoreload, which adds auto-refreshing for a Sails project's API without having to manually restart the server.

If you’re interested in developing a plugin for Sails, you will most often want to make a hook.

* Core hooks, like http, request, etc. are hooks which are bundled with Sails out of the box. They can be disabled by specifying a hooks configuration in your .sailsrc file, or when lifting Sails programatically.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.