Convex Community

CC

Convex Community

Join the Convex Discord! Explore Convex, the fullstack TypeScript platform for developers and startup founders.

Join

support-community

show-and-tell

general

open-source

announcements

Advice Optimizing Search and Filters

Hi everyone, I'm working on a database project for Commonwealth case law and need some advice on optimizing my search and filter functionality. Here's my current setup and questions: 1. Overview...

Call internalAction in 'use node' environment, from a mutation

Hello, how can I call internalAction from a mutation, In the mutation ctx I don't have any option to do it. Is this possible?

efficiency of: return (await ctx.db.query("messages").collect()).length;

that does not seem very efficient if I had 1mil rows in a table. Two suggestions/questions: 1. Is there a count of a table (without scanning the whole table)? 2. Alternatively, should there not a some for of projection? What if I had a table with 50 columns and I need a list that really only contains 2 or 3 of the columns?...

Require cycle issues, can't seem to troubleshoot to where its coming from

Hello, I'm getting this error when starting my expo web server. And have tried troubleshooting it for a while now, but can't seem to find any place where this import cycle happens that has anything to do with the files mentioned in the error: Can anyone from the convex team, help me shine some light on this and where i could maybe look and check?...

Best pattern for mutation after query

I'm simplifying my use case quite a bit but essentially on page load, I'd like to update the user's stats at specific intervals (week, month, etc). I understand that I can't call a mutation within a query, and I've read another support ticket Mutations Inside Queries where the suggestion was to simply invoke a mutation. This will work but given that a significant portion of the user's view will be dependent on the results from this mutation, this feels a little hacky as I'm incorporating useEffect + some state to fetch the data, while also having to setup a separate query in order to see the data in realtime. I'll also have to add some code to deal with a potential flicker since the order of operations is results from query, then results from mutation....

Querying for random record

I was wondering if there is a standard way for querying for a random record. Some ways I have thought about achieving this: - Counting number of records and generating a number between 0 - n (falls over on deleted records and relies on a lengthy count call) - Creating indexes that reoorder and then query the indexes....

Turbo Repo Exmaple

Is there any turbo repo example sharing convex across few projects like nextjs, nestjs etc?

Query data from Backend

Is there any resource / examples on how to query data from backend? Like ElysiaJS or NestJs?

convex x hono

i'm not able to make the hono .notfound endpoint work. i get errors if i just visit a wrong path rather it showing a message of not found or something. ```import { Hono } from "hono";...

Client side caching / costs?

Hello! Looking at Convex, I noticed that it is recommended to have a useQuery for pretty much every data read—which makes sense, at least for initial application render. But is there any client side caching to prevent repetitive function calls for data that isn't updating? Thinking of apps where you may call several queries per page, but the underlying data isn't changing regularly (profile photos, names, titles of documents, etc)—so it seems like you're unnecessarily going to rack up a large amount of function calls. Curious if this is something to think about, or not? Obviously free tier gets you very far, but just curious from an architecture/data fetching standpoint what the "best" E2E strategy is for both BE/FE performance and usage stats....

api routes with next-intl

Hi, I'm using convex password auth with nextjs and it was working fine, but then i implemented next-intl and now the api routes are returning 404 i've tried to make the next-intl dont run on the api routes but then in also return an error on the next-intl saying that: Unable to find next-intl locale because the middleware didn't run on this request. See https://next-intl-docs.vercel.app/docs/routing/middleware#unable-to-find-locale. The notFound() function will be called as a result....
No description

convex logs only last for 1 day ? I need 3 weeks at least

I like how railway logs works, can anyone give a better recommendation ?

How do I skip queries when using convex with tanstack query.

I am passing a conditional boardId but only want the query to run if and only if the boardId is present. I have tried all these but none of them work: ```...

OptimisticUpdate

I'm using action to first send a post to third party service and then inserting into DB, the question is how to use the optimistic on the frontend, to insert into the localstorage? //getData ```js const { results, status, loadMore } = usePaginatedQuery(...

Setting auth from within an HTTP action

I am using navigator.sendBeacon() to call an HTTP action on page unload, which in turn uses runMutation() to call one of my mutations. This generally works ok, but sendBeacon() cannot be configured to send headers like Authorization. I can pass the JWT via the POST body, but once I receive it within the HTTP action I am not sure how to then configure convex to use this JWT, to somehow call my runMutation with the JWT context, or to otherwise validate the JWT and extract my user information so th...

convex auth - getting logged out after 1 day

Hi guys, I'm using OTP, often overnight when I get back to my app I can't fetch anything and get this message(see image). I'm also listening to isAuthenticated at the root of my app: const { isAuthenticated, isLoading } = useConvexAuth();...
No description

auth - vanilla js app

Hi. I’m using vanilla js but realized that convex auth mainly support apps with the react framework. It was suggested to me to check out Clerk Auth. I’m just a bit unclear on whether it’s feasible for me to use Clerk auth in my app and successfully link its functionality and user validation back to Convex with my vanilla js app.

create a method to query on demand?

how do i create a action method that can query the database on demand to be used on the frontend, i tried to use internalquery with a action, but the action didnt allow me to return the internal query? I need to use it in the frontend on demand...

Bug when using convex auth with password

Not sure if this is a bug but when following the docs https://labs.convex.dev/auth/config/passwords#add-sign-in-form for using convex auth with passwords, but when doing a sign up via the sign in function, I am getting back an error about the providerID? It should be created right? ```Uncaught Error: Uncaught Error: Index authAccounts.providerAndAccountId not found. at createAccountFromCredentialsImpl (../../node_modules/@convex-dev/auth/dist/server/implementation/mutations/createAccountFromCredentials.js:26:34) at storeImpl (../../node_modules/@convex-dev/auth/dist/server/implementation/mutations/index.js:93:8) at handler (../../node_modules/@convex-dev/auth/dist/server/implementation/index.js:280:12)...

Uncaught Error: Invalid state

My convex app has multiple Sentry errors like these Uncaught Error: Invalid state at userOAuthImpl (../../node_modules/.pnpm/@convex-dev+auth@0.0.65_convex@1.15.0_react-dom@18.3.1_react@18.3.1react@18.3.1next@14.2._i2itvx7lmm5kie4gtz2mpmhyoq/node_modules/@convex-dev/auth/dist/server/implementation/mutations/userOAuth.js:25:4)...
No description