Get started
- Create a new Node/Bun project
bash
bun init- Install Minoro as a dependency
bash
bun add minoro@latest- Install a Standard Schema compatible validation library
bash
# bun add valibot
# bun add arktype
bun add zod- Create your config file in
index.ts(or any other file)
ts
import { createMinoro, defineView } from 'minoro'
import { z } from 'zod'
const simpleView = defineView(
{ name: 'Simple view', icon: 'lucide:info' },
(view) => {
view.defineText({
text: 'This is a simple view with a button.',
})
view.defineButton({
label: 'Do something',
action: async () => {},
})
},
)
// we use zod to validate the environment variables
const env = z
.object({
DATABASE_USER: z.string(),
DATABASE_PASSWORD: z.string(),
DATABASE_HOST: z.string(),
DATABASE_PORT: z.string().optional().default('5432'),
DATABASE_NAME: z.string(),
FRONTEND_URL: z.string(),
PORT: z.coerce.number().optional().default(3000),
})
.parse(process.env)
const minoro = createMinoro({
// Pass the view we want to use
views: [simpleView],
// The public URL or you admin UI e.g. https://example.com
allowedOrigins: [env.FRONTEND_URL],
// The admin token that will be used to create your first admin user
ONE_TIME_ADMIN_TOKEN: 'EXAMPLE',
// Connect to your database
async setup() {
return {
database: {
type: 'postgres',
connection: `postgres://${env.DATABASE_USER}:${env.DATABASE_PASSWORD}@${env.DATABASE_HOST}:${env.DATABASE_PORT}/${env.DATABASE_NAME}`,
},
}
},
})
await minoro.ready
// serve the ui directly, we could also choose to host it on a CDN or anywhere else
await minoro.serveStaticUi()
// Start!
Bun.serve({ fetch: minoro.fetch, port: env.PORT })- Run your admin UI!
bash
bun run index.tsOn first boot, you should visit the /setup?token=your-one-time-token route to set up your first admin user, you will then be able to login.
More complete examples can be found in the Deployment documentation.