The Node.js Framework for Real-Time MongoDB Apps

Build web applications without worrying about

database configuration, data loading, authentication, cron jobs

- all done for you

Get Started

Backend Focused

Either add Modelence to an existing Next.js project or set up from scratch using the built-in Vite + React frontend.

MongoDB Data Models

Define your schema and indexes along with your collection in one place, then store and retrieve data anywhere in your code.

Authentication

Ready-to-use user system in your own database, with provided login, signup and logout methods, password encryption and hashing.

Works with

TypeScript
React
Vite
Next.js
MongoDB
OpenAI

Use Modelence Store and schema to define your data storage in MongoDB collections along with helper methods for document models

import { Store, schema } from 'modelence/server';

export const dbTodos = new Store('todos', {
  schema: {
    title: schema.string(),
    isCompleted: schema.boolean(), 
    dueDate: schema.date().optional(),
    userId: schema.userId(),
  },
  indexes: [
    { key: { dueDate: -1 } }
  ],
  methods: {
    isOverdue() {
      return this.dueDate < new Date();
    }
  }
});

Use Module to list your stores, cron jobs and other definitions

import { Module, time } from 'modelence/server';

export default new Module('todo', {
  stores: [dbTodos],
  cronJobs: {
    sendReminders: {
      description: 'Send reminders for overdue todos',
      interval: time.hours(24),
      async handler() {
        const overdueTodos = await dbTodos.fetch({
          isCompleted: false,
          dueDate: { $lt: new Date() }
        });
        overdueTodos.forEach(todo => {
          // Send reminder email
        });
      }
    }
  }
});

Use TanStack Query-style useQuery and useMutation hooks to interact with your backend from React

import { useQuery } from 'modelence/client';

function TodoItem({ todoId }) {
  const {
    data: todo,
    isFetching,
    error
  } = useQuery('todo.getOne', { id: todoId });
  if (isFetching) {
    return <div>Loading...</div>;
  }
  if (error) {
    return <div>Error: {error.message}</div>;
  }
  return <div>{todo.title}</div>;
}

Cron Jobs

Simply define a handler function and it will run at your specified time interval, with sub-second precision and cron job orchestration for multiple application instances.

Data Loading

Define queries and mutations to send and retrieve data between the client and server. Use React hooks on the client to fetch data, handle errors and loading state with a single statement.

Telemetry

All cron jobs and method calls are automatically logged and traced, so you can see full insights in your application's performance dashboard in Modelence Cloud.

App Configuration

Define dynamic app configuration values, and call getConfig on both client & server to use your configuration values anywhere in your code.

Database Migrations

Seamless migration scripts and versioning support to manage your database structure changes in multiple environments without any manual steps.

Type-Safe Development

End-to-end TypeScript support with automatic type inference for your data models, methods and database queries.

Why Modelence?

Creators of Modelence have been building production web applications for the last 17+ years and kept facing the same standard challenges over and over again. While each application and product was different, many of the challenges were the same. They had to spend a lot of time on adding support for authentication, data loading, cron jobs, monitoring and many other features that were common for all applications. Eventually, they combined all core building blocks into a single framework & platform on top of which you can start building your application logic right away.