Parse Server

9.8.0 · active · verified Sun Apr 19

Parse Server is a self-hostable, open-source backend for applications, providing a compatible API for the Parse platform SDKs. It enables developers to migrate their applications from the hosted Parse.com service (which was deprecated) to their own infrastructure, offering full control over their data and backend logic. The current stable version is 9.8.0. The project maintains an active development pace with frequent alpha releases for new features and bug fixes, typically leading to stable minor versions every few weeks or months. Key differentiators include its adherence to the Parse API specification, allowing seamless migration, extensive customization via Cloud Code and webhooks, and flexible database support (primarily MongoDB and PostgreSQL). It integrates directly with Express.js, making it easy to embed into existing Node.js applications.

Common errors

Warnings

Install

Imports

Quickstart

Sets up a basic Parse Server instance with Express.js, connecting to a MongoDB database, enabling Cloud Code, Live Queries, and a basic email adapter for user verification.

import express from 'express';
import { ParseServer } from 'parse-server';
import path from 'path';

const app = express();
const port = 1337; // Port for your Express app

// Database connection string (e.g., MongoDB, PostgreSQL)
const databaseUri = process.env.DATABASE_URI ?? 'mongodb://localhost:27017/dev';

// Initialize Parse Server
const parseServerApi = new ParseServer({
  databaseURI: databaseUri,
  cloud: path.join(__dirname, 'cloud/main.js'), // Path to your Cloud Code
  appId: process.env.APP_ID ?? 'myAppId',
  masterKey: process.env.MASTER_KEY ?? 'myMasterKey',
  serverURL: process.env.SERVER_URL ?? `http://localhost:${port}/parse`, // Your Parse Server URL
  liveQuery: {
    classNames: ['Post', 'Comment'], // Classes to enable for Live Queries
  },
  // Ensure publicServerURL matches the client-facing URL for file uploads, etc.
  publicServerURL: process.env.PUBLIC_SERVER_URL ?? `http://localhost:${port}/parse`,
  verifyUserEmails: true,
  emailAdapter: {
    module: 'parse-server-simple-mailgun-adapter',
    options: {
      fromAddress: 'no-reply@example.com',
      domain: process.env.MAILGUN_DOMAIN ?? 'example.com',
      apiKey: process.env.MAILGUN_API_KEY ?? 'YOUR_MAILGUN_API_KEY',
    },
  },
});

// Mount the Parse API on the /parse URL prefix
app.use('/parse', parseServerApi.app);

// Basic Express route
app.get('/', (req, res) => {
  res.status(200).send('Parse Server is running.');
});

// Start the Express server
app.listen(port, function() {
  console.log(`Parse Server running on http://localhost:${port}`);
  console.log('Make sure your database (e.g., MongoDB) is also running!');
});

// Example Cloud Code (./cloud/main.js):
/*
Parse.Cloud.define('hello', (request) => {
  return 'Hello from Cloud Code!';
});
*/

view raw JSON →