-
Notifications
You must be signed in to change notification settings - Fork 84
How to connect Triplit to Better Auth? #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
You need to use a Database Adapter, I created one here: https://github.com/daveyplate/better-auth-triplit |
Awesome, thanks.
I'm currently facing some trouble when deploying to production.
In local dev mode, the connection between Triplit and Better Auth works
flawlessly, but when deployed (I'm using Vercel for prod) I get an error
when trying to signup a user.
It seems to be related to JWT but I don't know what to do exactly.
On my triplit.dev/dashboard I've added my Better Auth Secret to the "External
JWT secret" field and *data.session.token* to the "External JWT path"
field, with no success.
Is there something I'm missing? Would appreciate any help I could get.
Atenciosamente,
Mauricio Fragale
Em qui., 22 de mai. de 2025 às 22:20, daveycodez ***@***.***>
escreveu:
… *daveycodez* left a comment (aspen-cloud/triplit#362)
<#362 (comment)>
You need to use a Database Adapter, I created one here:
https://github.com/daveyplate/better-auth-triplit
—
Reply to this email directly, view it on GitHub
<#362 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAIHRXXWUQ67FUVFJ5HGX3327ZZWRAVCNFSM6AAAAAB5UCO3E2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMBSHE4TQNRSHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Oh, the error:
[2m2025-05-26T19:32:02.555Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#13 [0m [40m [33m[1/3] [0m [1mfindOne [0m: {
model: 'users',
where: [
{
operator: 'eq',
connector: 'AND',
field: 'email',
value: ***@***.***'
}
],
select: undefined
}
[Triplit Adapter] Find One Fetch: users ***@***.***"]]
[Triplit Adapter] Find One Entity: users null
[2m2025-05-26T19:32:02.757Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#13 [0m [40m [33m[2/3] [0m [1mfindOne [0m [2m(DB Result) [0m:
{ model: 'users', data: null }
[2m2025-05-26T19:32:02.757Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#13 [0m [40m [33m[3/3] [0m [1mfindOne [0m [2m(Parsed Result)
[0m: { model: 'users', data: null }
[2m2025-05-26T19:32:03.217Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#14 [0m [40m [33m[1/4] [0m [1mcreate [0m [2m(Unsafe Input)
[0m: {
model: 'users',
data: {
createdAt: 2025-05-26T19:32:03.217Z,
updatedAt: 2025-05-26T19:32:03.217Z,
emailVerified: false,
email: ***@***.***',
name: 'Mauricio Fragale',
image: undefined
}
}
[2m2025-05-26T19:32:03.217Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#14 [0m [40m [33m[2/4] [0m [1mcreate [0m [2m(Parsed Input)
[0m: {
model: 'users',
data: {
name: 'Mauricio Fragale',
email: ***@***.***',
emailVerified: false,
createdAt: 2025-05-26T19:32:03.217Z,
updatedAt: 2025-05-26T19:32:03.217Z,
id: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU'
}
}
[Triplit Adapter] Insert: users {"name":"Mauricio Fragale","email":"
***@***.***
","emailVerified":false,"createdAt":"2025-05-26T19:32:03.217Z","updatedAt":"2025-05-26T19:32:03.217Z","id":"2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU"}
[2m2025-05-26T19:32:03.495Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#14 [0m [40m [33m[3/4] [0m [1mcreate [0m [2m(DB Result) [0m: {
model: 'users',
res: {
id: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
name: 'Mauricio Fragale',
email: ***@***.***',
emailVerified: false,
createdAt: 2025-05-26T19:32:03.217Z,
updatedAt: 2025-05-26T19:32:03.217Z
}
}
[2m2025-05-26T19:32:03.495Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#14 [0m [40m [33m[4/4] [0m [1mcreate [0m [2m(Parsed Result)
[0m: {
model: 'users',
data: {
name: 'Mauricio Fragale',
email: ***@***.***',
emailVerified: false,
image: undefined,
createdAt: 2025-05-26T19:32:03.217Z,
updatedAt: 2025-05-26T19:32:03.217Z,
id: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU'
}
}
[2m2025-05-26T19:32:03.495Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#15 [0m [40m [33m[1/4] [0m [1mcreate [0m [2m(Unsafe Input)
[0m: {
model: 'accounts',
data: {
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
providerId: 'credential',
accountId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
password:
'356a8fa054a346365551a0bc1162e14a:1459466977d822b5da063eff45825a278fd8602a5bb8be8e5c970a17f53344332d475b579d17cb7cce868583267c61d4d2b7c2b9072d2fc9eae4d0d62195fc1f',
createdAt: 2025-05-26T19:32:03.495Z,
updatedAt: 2025-05-26T19:32:03.495Z
}
}
[2m2025-05-26T19:32:03.495Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#15 [0m [40m [33m[2/4] [0m [1mcreate [0m [2m(Parsed Input)
[0m: {
model: 'accounts',
data: {
accountId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
providerId: 'credential',
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
password:
'356a8fa054a346365551a0bc1162e14a:1459466977d822b5da063eff45825a278fd8602a5bb8be8e5c970a17f53344332d475b579d17cb7cce868583267c61d4d2b7c2b9072d2fc9eae4d0d62195fc1f',
createdAt: 2025-05-26T19:32:03.495Z,
updatedAt: 2025-05-26T19:32:03.495Z,
id: 'dxHMEXnOLfGNC1Mjfn31ItUheXIbITTv'
}
}
[Triplit Adapter] Insert: accounts
{"accountId":"2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU","providerId":"credential","userId":"2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU","password":"356a8fa054a346365551a0bc1162e14a:1459466977d822b5da063eff45825a278fd8602a5bb8be8e5c970a17f53344332d475b579d17cb7cce868583267c61d4d2b7c2b9072d2fc9eae4d0d62195fc1f","createdAt":"2025-05-26T19:32:03.495Z","updatedAt":"2025-05-26T19:32:03.495Z","id":"dxHMEXnOLfGNC1Mjfn31ItUheXIbITTv"}
[2m2025-05-26T19:32:03.655Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#15 [0m [40m [33m[3/4] [0m [1mcreate [0m [2m(DB Result) [0m: {
model: 'accounts',
res: {
id: 'dxHMEXnOLfGNC1Mjfn31ItUheXIbITTv',
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
accountId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
providerId: 'credential',
password:
'356a8fa054a346365551a0bc1162e14a:1459466977d822b5da063eff45825a278fd8602a5bb8be8e5c970a17f53344332d475b579d17cb7cce868583267c61d4d2b7c2b9072d2fc9eae4d0d62195fc1f',
createdAt: 2025-05-26T19:32:03.495Z,
updatedAt: 2025-05-26T19:32:03.495Z
}
}
[2m2025-05-26T19:32:03.655Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#15 [0m [40m [33m[4/4] [0m [1mcreate [0m [2m(Parsed Result)
[0m: {
model: 'accounts',
data: {
accountId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
providerId: 'credential',
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
accessToken: undefined,
refreshToken: undefined,
idToken: undefined,
accessTokenExpiresAt: undefined,
refreshTokenExpiresAt: undefined,
scope: undefined,
password:
'356a8fa054a346365551a0bc1162e14a:1459466977d822b5da063eff45825a278fd8602a5bb8be8e5c970a17f53344332d475b579d17cb7cce868583267c61d4d2b7c2b9072d2fc9eae4d0d62195fc1f',
createdAt: 2025-05-26T19:32:03.495Z,
updatedAt: 2025-05-26T19:32:03.495Z,
id: 'dxHMEXnOLfGNC1Mjfn31ItUheXIbITTv'
}
}
[2m2025-05-26T19:32:03.655Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#16 [0m [40m [33m[1/4] [0m [1mcreate [0m [2m(Unsafe Input)
[0m: {
model: 'sessions',
data: {
ipAddress: '201.29.81.220',
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
expiresAt: 2025-06-02T19:32:03.655Z,
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
token: 'uss4uzCAIfMThuOVJ6rvIa8Vahu7UKcp',
createdAt: 2025-05-26T19:32:03.655Z,
updatedAt: 2025-05-26T19:32:03.655Z
}
}
[2m2025-05-26T19:32:03.655Z [0m [34mINFO [0m [1m[Better Auth]: [0m [Triplit
Adapter] [35m#16 [0m [40m [33m[2/4] [0m [1mcreate [0m [2m(Parsed Input)
[0m: {
model: 'sessions',
data: {
expiresAt: 2025-06-02T19:32:03.655Z,
token: 'uss4uzCAIfMThuOVJ6rvIa8Vahu7UKcp',
createdAt: 2025-05-26T19:32:03.655Z,
updatedAt: 2025-05-26T19:32:03.655Z,
ipAddress: '201.29.81.220',
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/136.0.0.0 Safari/537.36',
userId: '2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU',
id: 'vBtHWfDD5K2pe9YDRYJxjJeXxqx00lT8'
}
}
[Triplit Adapter] Create JWT token for userId:
2Sn0klfIhQdFgQbiuHo5N0wo6nSVbLxU
# SERVER_ERROR: Error: [Triplit Adapter] User not found
at Object.create (.next/server/chunks/986.js:30:8926)
at async Object.create (.next/server/chunks/986.js:30:18187)
at async createWithHooks (.next/server/chunks/986.js:35:6324)
at async Object.createSession (.next/server/chunks/986.js:35:8854)
at async (.next/server/chunks/986.js:148:43196)
at async i (.next/server/chunks/986.js:119:275850)
at async r.<computed> (.next/server/chunks/986.js:148:47867)
at async n (.next/server/chunks/986.js:148:2734)
at async handler (.next/server/chunks/986.js:148:3008)
Atenciosamente,
Mauricio Fragale
Em seg., 26 de mai. de 2025 às 23:42, Mauricio Fragale ***@***.***>
escreveu:
… Awesome, thanks.
I'm currently facing some trouble when deploying to production.
In local dev mode, the connection between Triplit and Better Auth works
flawlessly, but when deployed (I'm using Vercel for prod) I get an error
when trying to signup a user.
It seems to be related to JWT but I don't know what to do exactly.
On my triplit.dev/dashboard I've added my Better Auth Secret to the "External
JWT secret" field and *data.session.token* to the "External JWT path"
field, with no success.
Is there something I'm missing? Would appreciate any help I could get.
Atenciosamente,
Mauricio Fragale
Em qui., 22 de mai. de 2025 às 22:20, daveycodez ***@***.***>
escreveu:
> *daveycodez* left a comment (aspen-cloud/triplit#362)
> <#362 (comment)>
>
> You need to use a Database Adapter, I created one here:
> https://github.com/daveyplate/better-auth-triplit
>
> —
> Reply to this email directly, view it on GitHub
> <#362 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AAIHRXXWUQ67FUVFJ5HGX3327ZZWRAVCNFSM6AAAAAB5UCO3E2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSMBSHE4TQNRSHA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
Are you using Next.js? |
Did you set your environment variable on Vercel dashboard for BETTER_AUTH_SECRET? |
Oh, leave External JWT path blank |
Yes, using next.js, envs on vercel all set and just now blanked the External JWT path from the Triplit dashboard, but still didn't work. Here's my codebase, if it helps: https://github.com/mfragale/triple-better |
Hey hit me up on Discord it'll be easier to help you there my username is daveycodez I'd suggest testing your production Triplit DB on next dev locally so we can identify if it's an issue on the Vercel app or local or both |
Sure, I've sent you a request on Discord. |
I think we're good to close this issue, we got it working. Had to do with using anon key for the server side HttpClient |
Hi, I'm trying to connect Better Auth to my Triplit DB with no success.
My auth.ts code looks like this:
When I try to sign up, I get this error:
Any idea where I've gone wrong?
The text was updated successfully, but these errors were encountered: