Parse Server
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
-
MongoNetworkError: failed to connect to server [localhost:27017] on first connect
cause The MongoDB database server is not running or is not accessible at the specified URI.fixEnsure MongoDB is running and accessible from the Parse Server host. Verify the `databaseURI` in your Parse Server configuration (e.g., `mongodb://localhost:27017/yourdbname`). -
Parse initialization failed: Invalid application id.
cause The `appId` configured in Parse Server does not match the `appId` used by your Parse SDK client.fixDouble-check that the `appId` value in your Parse Server configuration (e.g., `new ParseServer({ appId: 'YOUR_APP_ID' })`) is identical to the one your Parse SDK client uses to initialize. -
Error: Could not find Parse.Cloud.define for function 'myCloudFunction'
cause The specified Cloud Code function is not defined, or the Cloud Code file was not loaded correctly by Parse Server.fixVerify that your Cloud Code file (e.g., `cloud/main.js`) contains `Parse.Cloud.define('myCloudFunction', ...)` and that the `cloud` option in your Parse Server configuration points to the correct path. -
TypeError: Cannot read properties of undefined (reading 'app')
cause This usually indicates that `new ParseServer(...)` was not properly instantiated or its `app` property is being accessed before it's ready.fixEnsure `parseServerApi.app` is accessed only after `new ParseServer` has completed its initialization. Confirm all required configuration options (e.g., `appId`, `masterKey`, `databaseURI`) are provided.
Warnings
- breaking Multiple security vulnerabilities (GHSA-g4v2-qx3q-4p64, etc.) were addressed in versions 9.8.0 and subsequent alphas that fixed endpoints bypassing `_Session` and `_User` `protectedFields`. This may change behavior for applications that inadvertently relied on these bypasses.
- breaking Node.js engine requirements are very specific and frequently updated. Version 9.8.0 requires Node.js `^20.19.0`, `^22.12.0`, or `^24.11.0`. Running on unsupported Node.js versions may lead to unexpected behavior or failures.
- gotcha The `masterKey` provides unrestricted access and bypasses all ACLs/CLPs. It should be used with extreme caution and never exposed to client-side code. Misuse can lead to severe security breaches.
- gotcha Cloud Code is JavaScript/TypeScript code that runs on the Parse Server. Changes made to Cloud Code are not automatically reloaded in production environments without restarting the Parse Server instance. This can lead to stale logic.
- deprecated Older authentication methods or social login providers might become deprecated or require updated configurations as third-party APIs evolve. Always check the Parse Server documentation for the latest integration guides.
Install
-
npm install parse-server -
yarn add parse-server -
pnpm add parse-server
Imports
- ParseServer
const ParseServer = require('parse-server').ParseServer;import { ParseServer } from 'parse-server'; - ParseGraphQLServer
import { ParseGraphQLServer } from 'parse-server';import { ParseGraphQLServer } from 'parse-server/lib/GraphQL/ParseGraphQLServer'; - Config
import Config from 'parse-server/lib/Config';
import { Config } from 'parse-server';
Quickstart
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!';
});
*/