Skip to main content

Installation

This guide walks you through setting up a FluxKit project from scratch.

System Requirements

  • Node.js >= 18.0
  • npm >= 9.0 (or yarn / pnpm)
  • MongoDB >= 6.0 (local or hosted)
  • TypeScript >= 5.0 (recommended)

Create a New Project

mkdir my-app && cd my-app
npm init -y
npm install typescript tsx @types/node --save-dev
npx tsc --init

Install FluxKit

Every FluxKit application starts with the core wire:

npm install @fluxkitdev/core

Then add any additional wires your application needs:

# Authentication
npm install @fluxkitdev/auth

# Messaging (email, SMS, WhatsApp)
npm install @fluxkitdev/messaging

# File storage and CRUD
npm install @fluxkitdev/store

# Payments
npm install @fluxkitdev/pay

# Blockchain / Web3
npm install @fluxkitdev/onchain

# React UI components (frontend only)
npm install @fluxkitdev/ui

Environment Configuration

Create a .env file at the root of your project:

# Required
MONGODB_URI=mongodb://localhost:27017/myapp

# Auth wire
JWT_SECRET=your-secret-key
OAUTH_GOOGLE_CLIENT_ID=...
OAUTH_GOOGLE_CLIENT_SECRET=...

# Messaging wire
SMTP_HOST=smtp.example.com
SMTP_PORT=587
SMTP_USER=your@email.com
SMTP_PASS=your-password
TWILIO_SID=...
TWILIO_TOKEN=...

# Store wire
S3_BUCKET=my-bucket
S3_REGION=us-east-1
S3_ACCESS_KEY=...
S3_SECRET_KEY=...

# Pay wire
STRIPE_SECRET_KEY=sk_test_...
PAYPAL_CLIENT_ID=...
PAYPAL_CLIENT_SECRET=...

# Onchain wire
RPC_URL=https://mainnet.infura.io/v3/YOUR_KEY
PRIVATE_KEY=0x...

You only need to configure environment variables for the wires you use.

Basic Application

Create src/index.ts:

import { FluxKit } from "@fluxkitdev/core";
import { auth } from "@fluxkitdev/auth";
import { messaging } from "@fluxkitdev/messaging";
import { store } from "@fluxkitdev/store";

const app = new FluxKit({
wires: [auth(), messaging(), store()],
database: {
uri: process.env.MONGODB_URI,
},
server: {
cors: {
origin: ["http://localhost:5173"],
},
},
});

await app.start({ port: 3000 });
console.log("FluxKit is running on http://localhost:3000");

Run the Application

Add a start script to your package.json:

{
"scripts": {
"dev": "tsx watch src/index.ts",
"build": "tsc",
"start": "node dist/index.js"
}
}

Then run:

npm run dev

Verify Installation

Once your server is running, you can verify the REST APIs are mounted:

# Check if the auth endpoints are available
curl http://localhost:3000/auth/health

# Check if messaging endpoints are available
curl http://localhost:3000/messaging/health

TypeScript Configuration

Recommended tsconfig.json settings:

{
"compilerOptions": {
"target": "ES2022",
"module": "ESNext",
"moduleResolution": "bundler",
"esModuleInterop": true,
"strict": true,
"outDir": "dist",
"rootDir": "src",
"declaration": true,
"skipLibCheck": true
},
"include": ["src"]
}

Next Steps