Encriva for Developers

Better-Auth Enchanced/Plugins

Feedback

This plugin provides feedback collection and management for your Better Auth application. By default, authentication is required to submit feedback, but this can be configured.

Installation

import { feedback, feedbackClient } from "@encriva/better-auth-enchanced";

To use this plugin in your application, you need to register it in both client and server configurations.

Initialize plugin

auth.ts
export const auth = betterAuth({
  plugins: [
    feedback({
      authRequired: true,
      adminRoles: ["admin"]
    })
  ]
});
auth-client.ts
const authClient = createAuthClient({
  plugins: [
    feedbackClient()
  ]
});

Usage

To submit feedback on the client side:

// To submit feedback
authClient.feedback.submit({
  response: "Test",
  location: "/"
});

API

PropTypeDefault
onSubmit?
(feedback: Feedback) => Promise<void>
-
schema?
Record<string, any>
-
adminRoles?
string[]
[]
authRequired?
boolean
true
enabled?
boolean
true

Error Codes

CodeDescription
FEEDBACK_NOT_FOUNDFeedback not found
SYSTEM_DISABLEDFeedback system is currently disabled
UNAUTHORIZEDYou must be logged in to view feedbacks
UNAUTHORIZED_SUBMITYou must be logged in to submit feedback
ADMIN_REQUIREDYou must be an admin to perform this action

On this page