Getting Started

Welcome to Lucent.

Lucent is an Elysia plugin that generates CRUD, auth, migrations, and OpenAPI from your collection definitions.

Create a Project

bun create lucent my-project
cd my-project
bun install

You can also use the CLI directly:

lucent init my-project

Minimal Setup

  1. Configure the environment:
DATABASE_URL=postgresql://postgres:password@localhost:5432/lucent_example
JWT_SECRET=dev-secret-change-before-production-123
SESSION_SECRET=dev-session-secret-change-before-prod-123

See Environment for the canonical env reference.

  1. Define your config:
import { defineLucentConfig } from "@codesordinatestudio/lucent";
import { Collections } from "./collections";

export default defineLucentConfig({
  db: {
    adapter: "postgres",
    url: process.env.DATABASE_URL,
  },
  auth: {
    strategies: ["jwt"],
    jwt: {
      secret: process.env.JWT_SECRET,
    },
  },
  collections: Collections,
});
  1. Define a collection:
import { defineCollection } from "@codesordinatestudio/lucent";

export const Users = defineCollection({
  slug: "users",
  auth: true,
  fields: [
    { name: "email", type: "email", required: true, unique: true },
    { name: "password", type: "password", required: true },
    { name: "name", type: "text" },
  ],
});
  1. Start development:
lucent dev
  1. Generate types or run migrations manually when needed:
lucent typegen
lucent migrate --dry-run
lucent migrate

Next Steps