Json πΊ
Explore posts from serversBABetter Auth
β’Created by Json πΊ on 4/9/2025 in #help
Custom values into `authClient.signIn.social()`?
Hey there π What's the best way to manually set user values when signing a user in through an OAuth provider? For example, I may want to set a custom, default user image instead of using your social provider image, or I may want a custom name or username. Since I am using Next.js, intercepting the user with a layout function is pretty trivial, but maybe there is some Better-Auth way to do this through hooks or something similar?
5 replies
Exposing server-side caller and tRPC caller/helper through the same export?
Hey there π I'm wondering if anyone thinks it could be unwise to expose the server-side caller and the tRPC caller through the same export.
I would prefer to use both through a single export, but I'm unsure if could be bad practice. Any thoughts are appreciated.
2 replies
TTCTheo's Typesafe Cult
β’Created by Json πΊ on 3/21/2025 in #questions
t3.chat background texture?
Hey there π any idea where I can find a simple texture such as the one used in t3.chat or motion.dev? I'd like one that works with both light and dark theme, but I am unsure where to begin looking. Any help is appreciated.
4 replies
BABetter Auth
β’Created by Json πΊ on 2/8/2025 in #help
Correct way to determine the baseURL?
Hey there π
What is the recommended way in Next.js to determine the baseURL on the client?
The docs tell us to create an environment variable
BETTER_AUTH_URL
. However, I don't see where the docs recommends that we use this env variable. On the client, the example used only shows an explicitly defined string. In Next.js, I have used the following:
However, I am inclined to follow a method usually used in tRPC. On the client, we typically do something like this to determine the URL:
So, should we really just be using a function like getBaseUrl()
on the client to determine the auth location? Also, is BETTER_AUTH_URL
used somewhere internally that I'm not seeing?6 replies
BABetter Auth
β’Created by Json πΊ on 2/1/2025 in #help
Has anyone used getSession() with tRPC callers?
Iβm curious if anyone has used callers with the server-side validation. Because callers seem to exist outside of the global Next.js request scope, passing headers into getSession() doesnβt seem to be possible.
Id like to use all of my data access functions on the server through my tRPC procedures, but my context which contains session info calls headers() outside of the request scope.
Any experience/ideas?
14 replies
TTCTheo's Typesafe Cult
β’Created by Json πΊ on 12/24/2024 in #questions
When is transcoding coming?
I am very excited that transcoding appears to be on the UT roadmap. Any idea when this might be?
2 replies
PPrisma
β’Created by Json πΊ on 12/9/2024 in #help-and-questions
TypedSQL failing during build step
Hey there, I am having an issue where my SQL scripts run perfectly fine during developing but during my build step I am receiving the following error. I am unsure how to begin to debug this issue, so any suggestions are appreciated.
Here is the script in question:
getPostReactionsNoUser.sql
And finally, because I suspect this could be related, I will include my build script:
5 replies
BABetter Auth
β’Created by Json πΊ on 12/8/2024 in #help
Use deleteUser() without verification?
Is it possible to use the
deleteUser()
method without specifying sendDeleteAccountVerification
? I am constructing a simple demo app and would like this use this method without this.6 replies
PPrisma
β’Created by Json πΊ on 12/6/2024 in #help-and-questions
Error P1012 when trying to use Prisma Postgres
Hey there π I'm trying to use Prisma Postgres, but I am getting this error. I am unsure why the
DATABASE_URL
provided by Prisma would not work? Mine follows the format: prisma+postgres://accelerate.prisma-data.net/?api_key=..."
but I get the following error when running npx prisma migrate dev --name init
8 replies
BABetter Auth
β’Created by Json πΊ on 11/30/2024 in #bug-reports
Unable to use `mongodb` client
Hey there, I am having an issue using MongoDB with Better Auth. I have correctly initialized a mongodb client it seems, but Better Auth seems to be having an issue with it. If you have any pointers on how I might begin to debug this, I would greatly appreciate it.
Error following
authClient.signUp()
. I can send the full error if needed by I am limited by Discord's post length here. Here the database is connected successfully.
/lib/auth/server.ts
/lib/db/mongodb.ts
3 replies
PPrisma
β’Created by Json πΊ on 11/3/2024 in #help-and-questions
TypedSQL: Passing null values into raw SQL?
I am currently using an aggregate query that returns a boolean that is either true or false if some user (current user) has reacted to a given post. Here is the query (thanks Jon Harrell--if the code has issues it's likely because I've been modifying it):
And I want to be able to pass a null
userId
value if there is no current user into but unfortunately this does not work with the type error Argument of type 'string | null | undefined' is not assignable to parameter of type 'string'. Type 'undefined' is not assignable to type 'string'.ts(2345)
Up until now, I've been passing two functions conditionally when userId is not known:
But this doesn't play well with the type system, hence the explicit type casting since the only accepted types don't include null or undefined.
Is there a way to type this userId value as nullable/nullish, and execute this query without it? Any help is greatly appreciated!3 replies
BABetter Auth
β’Created by Json πΊ on 11/2/2024 in #bug-reports
Failed to get source map when using auth.api.getSession() during first request
Hey there π, I am having an issue getting my session on the server in a single request. Currently, it seems that two requests are being made for session data, and as for a brief moment, components accessing session data using
useSession()
render improperly.
Has anyone had this issue before? Where can I begin to debug?
36 replies
Fetch once and never again?
Hey there π, I'm wanting to fetch some data
reactionTypes
once when my layout <MainLayout />
renders in Nextjs and never again because this data does not change. Currently, I have placed (what I think is) a headless component into my layout that accesses the query client then sets a staleTime: Infinity
default on this specific query.
Is this a dumb strategy? How might you do this differently?
2 replies
Opinionated help: Where to place data access functions with respect to tRPC router(s)?
Hey there π I'm currently trying to decide where to place my data access functions with respect to my tRPC routers. Currently, I have them placed at
src/data-access/post/mutate-thing.ts
, and I am wanting to move them into a folder structure like this: src/server/routers/post/functions/mutate-thing.ts
but this feels a bit too nested (maybe not a bad thing) and for someone new to my codebase, this might make it difficult to find these functions.
My routers are all obviously defined at src/server/routers
, and I import my data access functions directly into each procedure within each router. Should I leave these data functions where they are at?2 replies
Dynamically generate url for httpBatchLink
Hey there π is it possible to generate a url for httpBatchLink instead of hardcoding one? I attempted the below code, but this doesn't work. Understandably, the fallback value is used for
url
each time the component mounts.
I believe that I wouldn't even need a useEffect if I wasn't using Next, as I could directly grab these values from window.location
, but since I'm using SSR, this code doesn't make it through the SSR pass.
3 replies
How to get pageParam from useInfiniteQuery()?
How would I write a tRPC call equivalent to this traditional
useInfiniteQuery
? My primary concern here is that I need to pass in a cursor to my procedure, and upon each successive query I need to update this cursor for the next call.
Maybe it should be something like this?
2 replies
TTCTheo's Typesafe Cult
β’Created by Json πΊ on 9/14/2024 in #questions
uploadthing replacing name and adding customId in middleware fails to run
This middleware does not run, despite this being close to what is provided in the documentation for changing file names and adding
customId
s (https://docs.uploadthing.com/file-routes#middleware). Logging the error provided by useUploadThing()
's onUploadError
gives UploadThingError: Failed to run middleware... Caused by: Object { β¦ }
1 replies
PPrisma
β’Created by Json πΊ on 8/28/2024 in #help-and-questions
Complicated groupBy query
Hey there, I am attempting to do something with Prisma that may be undoable. I am still very new to web dev and Prisma, so be aware I don't doubt I'm missing something obvious here.
I would like to use
post.findMany()
to find posts for a specific user, but in this query I would like to include the number of reactions
associated with a post for a kind of reactionType
. In my project, I am using emoji reactions on posts, and I need to return the number of reactions per emoji type (reactionType
). However, I am at a loss for how to do this without many queries per request.
Using groupBy()
works if I grab the posts first and then use the post.id
of each post...
^ This returns the following:
...and then merging the results from this with the original posts list, but this method is fairly complicated and I still haven't solved how to include a boolean value which indicates whether or not the current user has reacted to this post with a given emoji/reactionType
... this would require additional queries.
I think the ideal structure would be an object called reactionTypes
of the following type appended to the post
object:
... where the key here is the id
of the reactionType
like "U+2764
" which is the unicode for a red heart emoji. Of course, I don't exactly need this format, I just need this data π (i.e., reacted
boolean, count
number)
If anyone has thought about how I might be best include this reaction data, I would greatly appreciate it. I've been struggling for hours on this.
For schema-related details, see the below schema.prisma
(comment)7 replies
PPrisma
β’Created by Json πΊ on 6/6/2024 in #help-and-questions
Flat response from relational query?
I am trying to use the following Prisma query to get a post object back containing post details and the username of the user that posted it:
const posts = await prisma.post.findMany({
where: {
users: {
username: {
equals: username,
mode: "insensitive",
},
},
},
select: {
contentText: true,
users: {
select: {
username: true,
},
},
},
});
This returns
[
{
contentText: 'Embarking on a thrilling journey in Glacier National Park β°οΈ was an unforgettable experie
nce! Amidst stunning landscapes, we had a heart-pounding encounter with a majestic bear, a reminder of the
untamed beauty of nature. Days were spent foraging mushrooms π, adding a delicious touch to our lakeside feasts. Nights by the crackling fire on the lakeshore were filled with laughter, storytelling, and a deep sense of camaraderie. Surrounded by towering mountains and the tranquil lake, each moment felt like a cherished memory in the making. With my partner and friends by my side, we immersed ourselves in the serenity of the wilderness, forging bonds that will last a lifetime. πͺ' ,
users: { username: 'Alaskan' }
}
]
I would like username
to be level with contentText
without having to manually flatten the objects returned in this response array. How is this accomplished?4 replies