Database Hooks `before.create` Has Undefined Context

How is the context populated in the database before create hook? Taken from example here https://www.better-auth.com/docs/concepts/database#1-before-hook Code snippet below:
databaseHooks: {
session: {
create: {
before: async (session, context) => {
// context is always undefined here

return {
data: session
}
},
}
}
},
databaseHooks: {
session: {
create: {
before: async (session, context) => {
// context is always undefined here

return {
data: session
}
},
}
}
},
Database | Better Auth
Learn how to use a database with Better Auth.
4 Replies
Ping
Ping15h ago
It depends on how a given session was created, in some cases there can be no ctx.
Bruh
BruhOP15h ago
Yeah I see the parameter type as GenericEndpointContext | undefined. I'm trying to get the context during signup with oauth in the /callback/:id path.
Ping
Ping15h ago
I see, I'll look into the source code and see if I can add ctx.
Bruh
BruhOP13h ago
Sounds good, thank you.

Did you find this page helpful?