---
description: This guide will walk you through the process of deploying a MagicJS project.
---

# Deploying

## Deploying as a Standalone Node.js Application

**Step 1: Build the Project**

```bash
npm run build
```

**Step 2: Start the Server**

Once the project is built, you can start the server using:

```bash
node build/server/main.js
```

{% hint style="info" %}
For production deployments, it's recommended to use a process manager like PM2 to ensure robustness and ease of management.
{% endhint %}

**Step 3: Using PM2 (Recommended)**

Install PM2 globally if you haven't already:

```bash
npm install -g pm2
```

Now, start your MagicJS application using PM2:

```
pm2 start build/server/main.js --name my-magic-app
```

{% hint style="info" %}
This will start your MagicJS application as a background process, and PM2 will handle logging, monitoring, and automatic restarts.
{% endhint %}

## Deploying as a Container

Documentation for deploying MagicJS as a container is currently under development and will be available soon. Stay tuned for updates!

## Some of the best practices to consider before deploying.

* **Environment Configuration**: Make sure to configure your environment variables appropriately for your production environment.
* **Security Considerations**: Implement security best practices, including proper firewall configurations and secure connection settings.
* **Monitoring**: Use monitoring tools to keep an eye on your application's performance and health.
