'"better-auth/plugins"' has no exported member 'sessionMiddleware'.

Expected behaviour:
I should be able to import sessionMiddleware from the better-auth plugin to verify if a user has an active session.

Current behaviour:
When attempting to use sessionMiddleware from the better-auth plugin, I encounter an error indicating that the module has no exported member named sessionMiddleware.

Better-Auth version
v1.1.3 (Latest)

Reproduction Steps

  1. Install the better-auth plugin (v1.1.3).
  2. Attempt to import and use sessionMiddleware in the code.
  3. Encounter the error: "Module has no exported member 'sessionMiddleware'."
Purpose
I am building an Attribute-Based Access Control (ABAC) proof of concept using better-auth by creating a custom plugin. The sessionMiddleware is a key component for session validation in this context.

Code Example
I have created a Gist containing the relevant code for replication and further context: Link to Gist... https://gist.github.com/AdzeB/ee733f6d4c8409e67babd89aefb9147d

Additional Information

I have followed the official documentation for better-auth but could not find references to the sessionMiddleware export.
The issue persists even after reinstalling the plugin and verifying the package integrity.
Request

  1. Can you confirm whether sessionMiddleware is officially supported and exported in version 1.1.3?
  2. If not, could you suggest an alternative or workaround for session validation?
  3. Additionally, I would appreciate any feedback on the implementation details provided in the linked Gist.
    Thank you for your assistance!
Gist
ABAC Proof of concept. GitHub Gist: instantly share code, notes, and snippets.
Was this page helpful?