Skip to content

Guide · Open source

How to use Sails: install, create an app and run it

Updated · written with AI from the project's own documentation and checked against our catalogue data

Sails.js is a web framework for Node.js that helps you build custom server-side apps and APIs. Its structure resembles the MVC pattern used in frameworks like Ruby on Rails, and it is especially suited to realtime features such as chat. This guide shows you how to install Sails, create and start a new project, and understand the basics of its database layer, Waterline.

Sails.jsbalderdashy/sails · ★ 22.8k · MIT

Quick start

  1. 1Check Node.js. Make sure Node.js is installed on your machine before continuing.
  2. 2Install Sails globally. Run npm install sails -g to install the latest stable release of Sails.
  3. 3Create an app. Run sails new my-app to generate a new project folder.
  4. 4Enter the folder. Run cd my-app to move into the project directory.
  5. 5Start the server. Run sails lift to start your Sails app.
  6. 6Read the docs. Follow the Get Started guide and documentation on sailsjs.com to build your first features.

What you need before you install Sails

Sails runs on Node.js, so Node.js must be installed first. The README links to the Node.js download page for this. Sails is built on Node.js, Express and Socket.io, so some familiarity with JavaScript and the Node.js ecosystem will help.

  • Node.js installed on your computer
  • Basic JavaScript knowledge

Install Sails with npm

With Node.js installed, install Sails globally using npm, the Node package manager. The README says to get the latest stable release this way.

npm install sails -g

Create and start a new Sails app

Use the sails command to create a new app in a folder called my-app. Then move into that folder and start the server with sails lift. You can rename my-app to any folder name you like.

sails new my-app cd my-app sails lift

How Sails handles data with Waterline

Sails includes Waterline, its ORM, which uses an adapter system to connect to different datastores. The README lists officially supported databases: MySQL, PostgreSQL, MongoDB, Redis, and local disk or memory. Community adapters exist for others, including SQLite, Oracle, MSSQL and DynamoDB.

Because the database is reached through adapters, you can in principle switch datastores. Check the Available Adapters page on the Sails website for the current list before you commit to a database.

  • Officially supported: MySQL, PostgreSQL, MongoDB, Redis, local disk / memory
  • Community adapters: CouchDB, neDB, SQLite, Oracle, MSSQL, DB2, ElasticSearch, Riak, neo4j, OrientDB, DynamoDB and more

Reuse Express code and add realtime features

The README says Sails actions are compatible with Connect middleware. In most cases you can paste code from an existing Express project into Sails and it will work. You can also use WebSockets to talk to your API, and the reverse.

Sails also supports async/await since version 1.0, which replaces nested callbacks with simpler code.

var orgs = await Organization.find();

Where to get help while learning Sails

The Sails website has documentation, a Get Started guide, and a FAQ. Community support and paid professional options are also listed there. The README points to tutorial courses and books if you prefer structured learning.

  • Documentation: sailsjs.com/documentation
  • Get started: sailsjs.com/get-started
  • FAQ: sailsjs.com/faq
  • Community support: sailsjs.com/support

What people use it for

  • Building a realtime chat feature that uses WebSockets alongside an HTTP API
  • Creating a custom server-side app or API with an MVC layout in Node.js
  • Moving code from an existing Express project into a more structured framework
  • Connecting an app to MySQL, PostgreSQL, MongoDB or another datastore through Waterline adapters

Frequently asked questions

What is Sails.js used for?

Sails.js is a web framework for Node.js for building custom server-side apps and APIs. The README says it is especially good for realtime features such as chat. It follows an MVC structure similar to Ruby on Rails.

How do I install Sails?

With Node.js installed, run npm install sails -g to install the latest stable release. Then create a project with sails new my-app and start it with sails lift.

What are the requirements for Sails?

The README lists Node.js as the prerequisite. Sails is built on Node.js, Express and Socket.io, so basic JavaScript knowledge is useful.

Is Sails free to use?

Sails is open source and released under the MIT licence. The source for this page does not cover pricing for professional or enterprise support, which the Sails website describes separately.

What databases does Sails support?

The README lists MySQL, PostgreSQL, MongoDB, Redis and local disk or memory as officially supported through Waterline. Many community adapters exist for other databases, but support depends on the adapter.

How does Sails compare to Express, NestJS, Fastify or Koa?

Sails is built on Express and includes a fairly complete MVC layout and an ORM, Waterline. Express, Fastify and Koa are more minimal, and NestJS is another structured Node.js framework. Pick Sails if you want built-in structure and realtime features, and a lighter option if you want little built-in structure.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Sails suits JavaScript developers who want a Rails-style MVC structure in Node.js, especially for realtime features like chat, or who are extending an Express project. It is less suitable for people new to JavaScript or Node.js, or for teams who want a minimal framework and need a database with no available adapter.

Install options & downloads