# Installation

URL: https://rivo.tools/docs/cfx-db-installation

#### Prerequisites

[Node.js 18+\\
JavaScript runtime (or use Bun as an alternative)](https://nodejs.org/) [Convex Account\\
Free tier available - create account first](https://convex.dev/)

#### Download

Clone the repository and navigate to the directory

```bash
# Download CFX-DB from GitHub
git clone https://github.com/CFX-Software/cfx-db.git
cd cfx-db
```

#### Install Dependencies

Choose your preferred package manager

```bash
npm install
```

#### Convex Setup

Initialize your Convex deployment and configure environment

```bash
# Initialize Convex project
bunx convex dev

# Follow prompts:
# 1. Create new project or use existing
# 2. Choose deployment (dev/prod)
# 3. Copy deployment URL

# Configure your .env file
CONVEX_URL=https://your-deployment.convex.cloud
CONVEX_DEPLOYMENT=dev:your-deployment-name
JWT_SECRET=your-secret-key-here
```

#### Build the Resource

Build the FiveM resource before deploying (REQUIRED)

```bash
npm run build
```

#### Deploy to FiveM

Copy the built resource to your FiveM server

```bash
# Copy the ENTIRE cfx-db folder to your resources directory
# For example: [FiveM]/resources/[database]/cfx-db

# Add to your server.cfg
ensure cfx-db

# Start your FiveM server
# CFX-DB will connect to Convex and initialize
```
