Documentation
Examples
Code Examples

Code Examples

Practical examples for deploying different frameworks on Moontraze.

JavaScript SDK

import MoonSDK from '@moontraze/sdk';
 
const moon = new MoonSDK({
  projectId: 'YOUR_PROJECT_ID',
  apiKey: 'YOUR_API_KEY',
});
 
const reg = await moon.auth.register('john@example.com', 'secret123', 'John');
moon.setToken(reg.token);
 
await moon.db.set(`users/${reg.user.id}`, {
  name: 'John',
  email: 'john@example.com',
});

→ Full JavaScript SDK docs

Next.js (Static Export)

next.config.js:

const nextConfig = {
  output: 'export',
  trailingSlash: true,
  images: { unoptimized: true },
};
 
module.exports = nextConfig;

Deploy:

npm run build
moon moontraze deploy --prod

→ Full Next.js guide

React (Create React App)

npm run build
moon moontraze deploy --prod

Output: build/ folder

Vue

npm run build
moon moontraze deploy --prod

Output: dist/ folder

Vite

npm run build
moon moontraze deploy --prod

Output: dist/ folder

Plain HTML

moon moontraze deploy --prod

No build step needed.


Backend Examples

Moontraze does not host backend code. For server-side logic, databases, or APIs, use a separate backend platform.

Recommended approach:

  1. Host your frontend on Moontraze
  2. Host your backend on a serverless or container platform
  3. Connect them via API calls

Popular backend options:

  • Serverless function platforms
  • Container hosting platforms
  • Virtual private servers (VPS)
  • Cloud providers

→ See supported frameworks