Api
API Reference
Detailed API Documentation for NextJS Base Components and Functions
📚 API Directory
Core API
Component API
SmartCrudPage
Universal Table Component Props
SmartForm
Universal Form Component Props
fieldsConfig
Field Configuration Details
Utility Library API
🔧 Quick Reference
wrapAction
import { wrapAction } from '@/lib/core/action-wrapper'
export const myAction = wrapAction(
'sysMyAction', // Action Name
async (params, ctx) => { // Handler Function
// ctx: { userId, user, isAdmin }
return { success: true, data: result }
},
{ skipLog: false } // Options
)createCrudActions
import { createCrudActions } from '@/lib/core/crud-helper'
export const {
getList,
getDetail,
create,
update,
delete: del,
} = createCrudActions({
modelName: 'post',
fields: { creatable: [...], updatable: [...] },
validation: { ... },
hooks: { ... },
})fieldsConfig
const fieldsConfig = [
{
key: 'name',
title: 'Name',
type: 'text',
table: { width: 200 },
form: { required: true },
search: { enabled: true, mode: 'like' },
},
]nb.pubfn
import nb from '@/lib/function'
// Time Handling
nb.pubfn.timeFormat(new Date(), 'yyyy-MM-dd')
// Array Operations
nb.pubfn.arrayUnique([1, 2, 2, 3])
// Object Operations
nb.pubfn.deepClone(obj)
// Validation
nb.pubfn.test('[email protected]','email')nb.cache
import nb from '@/lib/nb' // server only
await nb.cache.set('demo:key', { foo: 'bar' }, 60)
const value = await nb.cache.get('demo:key')
await nb.cache.incr('demo:counter', 120)Supports PostgreSQL (default) and Redis; use the
cacheManagefactory for custom instances. See cache docs for details.