Skip to content

Add subscription details to user for better-auth #199

@nperez0111

Description

@nperez0111

It'd be a really nice integration with Better-Auth, if we added a column for each user to store their current subscription status.

To give more context, in my website, I wanted to check the subscription status of the current signed in user, but not have to hit the Polar API for each request (why hit the Polar API when I already have access to my own DB).

So, what I did was add an additionalField to each of my users, and use the webhook events to change the subscription status of the user whenever the subscription changed:

https://github.com/TypeCellOS/BlockNote/blob/7fcafe493a7aa4d67eae147b03023165dd8d18a5/docs/auth.ts#L222-L248

This seems like it will work pretty well and reduce dependence on hitting the polar API for each one of my requests.

So, for the better-auth polar adapter, I think it would be great to add a new column for users which is a JSON.stringify'd version of the current subscription details. Then it would make it easy to access the current subscription state, rather than hitting the Polar API for it.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions