Create Your First App
Let’s build a real-time REST API in just a few minutes. We’ll create a messages service that automatically works via REST and WebSockets.Create a new Feathers application
Use the Feathers CLI to scaffold a new application:The CLI will ask you some questions about your project setup:
- Choose TypeScript or JavaScript
- Select your preferred database (we’ll use Memory for this quick start)
- Choose Express or Koa
- Select authentication options
Start the development server
Run the development server:Your Feathers API is now running at
http://localhost:3030!You should see output indicating the server started successfully. The app automatically restarts when you make changes.
Create your first service
Let’s create a simple in-memory service manually to understand the core concepts:This creates a fully functional REST API with the following endpoints:
app.ts
Understanding the Core Concepts
Services
Services are the heart of Feathers. They’re objects that implement specific methods for interacting with data:packages/feathers/src/service.ts
Custom Service
The Feathers Application
The Feathers application is created using thefeathers() function:
packages/feathers/src/application.ts
app.use(path, service)- Register a serviceapp.service(path)- Get a registered serviceapp.configure(callback)- Configure the applicationapp.listen(port)- Start the server
Adding Real-time with Socket.io
Add Socket.io support to enable real-time communication:Real-time
packages/socketio/src/index.ts
Client
Adding Hooks
Hooks are middleware for services. They run before, after, or around service methods:Hooks Example
packages/feathers/src/hooks.ts
Using Express Middleware
Since Feathers extends Express, you can use any Express middleware:Express Integration
Query Syntax
Feathers supports a rich query syntax for filtering data:Query Examples
Next Steps
Complete Tutorial
Build a full chat application with authentication
Authentication
Add JWT authentication to your app
Database Adapters
Connect to MongoDB, PostgreSQL, or other databases
Deployment
Deploy your Feathers app to production