Permix

A lightweight, framework-agnostic, type-safe permissions management library for client-side and server-side JavaScript applications.

import { createPermix } from 'permix'

interface Post {
  id: string
  published: boolean
}

// Create the permix instance
export const permix = createPermix<{
  post: {
    dataType: Post
    action: 'create' | 'update' | 'delete'
  }
}>()
import { permix } from './permix'

// Fetch the user
const user = await fetchUser()

// Setup the permissions
permix.setup({
  post: {
    create: true,
    edit: post => post ? !post.published : user.role === 'admin',
    delete: user.role === 'admin',
  },
})
import { permix } from './permix'

// Can I delete any post?
permix.check('post', 'delete')

const post = await fetchPost()

// Can I edit this post?
permix.check('post', 'edit', post)
🔒

Type-safe

Permix is built with TypeScript in mind, providing full type safety and autocompletion for your permissions system.

🌐

Framework Agnostic

Use Permix with any JavaScript framework or runtime - it works everywhere from React to Node.js.

🛠️

Simple DX

Permix provides an intuitive API that makes managing permissions straightforward and easy to understand.