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

How to check which user is signed in

Sorry all, I just can't find it in the docs. I found an article but the method shown is now deprecated. I'm using the convex auth implementation in react/expo, I assumed there would be a hook for the current user? 🙇🏻‍♂️...

Convex-Auth/NextJS/NPM (Not Vite)

Using https://github.com/get-convex/convex-auth-example as a baseline I have created a repo but even though the packages are installed I am getting errors that they cannot be found. - Cannot find module '@convex-dev/auth/server' or its corresponding type declarations. - Cannot find module '@convex-dev/auth/providers/Anonymous' or its corresponding type declarations.ts(2307) - Cannot find module '@convex-dev/auth/providers/Password' or its corresponding type declarations.ts(2307)...
No description

How can I re-use table validators?

If I define types in my table in my schema, how can I use them in functions and get the types?

Query Convex data from Next.js route.ts endpoint

Can I query data from Convex db in next.js route.ts endpoint? app/api/endpoint/route.ts ```ts...

Dashboard - export documents that match query

I don't see an easy way to export all documents that match a certain query as a jsonl file for instance, am I missing something?
No description

Access the action error message when fail

Hello, When I call an action that make a mutation to an external API, and the request fails, I get a Convex Error string, but I need to access the API response error message. ``` [CONVEX A(organizations_node:updateFacturapiCertificatesAction)] [Request ID: 14d31c10a571998b] Server Error Uncaught Error: El certificado no es un CSD. AsegĂşrate de no estar enviando una FIEL. at async handler (../convex/organizations_node.ts:230:6) Called by client...

Resources for Implementing User Roles

I'm looking to implement user roles for access control. Does anyone know if there are any specific resources, documentation, or best practices for setting up user roles with next.js, clerk and convex? How to intercept requests and check user roles Best practices for redirecting to role-appropriate routes Handling unauthorized access attempts...

using _storageId vs storing storage urls directly

How stable are the generated file storage URL´s, and could we rather than storing the _storage id field, just store the file storage URL from the start, like when a document is created and the file uploaded? Asking this because, im wondering if we could simplify a bunch of enrichments we are doing when querying documents, and their related data?...

OrganizationSwitcher from clerk not propogating org_id to convex getUserIdentity call

Perhaps I'm misunderstanding this technology, but I thought that you could use the OrganizationSwitcher component in clerk (assuming the org_id claim is set up in the jwt settings) to "tell" the user called from the getUserIdentity call in convex which org it is on (https://clerk.com/docs/components/organization/organization-switcher). That way, I don't have to deal with messy / arbitrary passing of orgIds & userIds from the front-end. Is there actually a correct way to do this?

Error when using withIndex (Index not found)

I can't seem to get indexes to work at all. I keep getting an Index not found error. I have attached the error message, my schema and query. I am able to get the query to work using filter but I want to take advantage of withIndex for perfomance. I even tried just a simple userId index and that didn't work either. Same error. Any idea what I could be doing wrong?...
No description

Auth is working in development but getting an error after deploying on Vercel

Getting Uncaught Error: Missing environment variable JWT_PRIVATE_KEY Should I be setting up this env variable before it can work on production? Following the convex-auth docs I assumed it would be alright out of the box. Appreciate any advice or help, thanks in advance! I did try generating a jwt private key and then repeatedly got this error: Uncaught Error: Missing environment variable JWKS . Wasn't really sure what I was doing at this point....

Whats the best practice/approach for saving and fetching convex images?

- Should I save storageId inside i.e product's table i.e thumbnail: v.id("_stareage") or should I have a separate table i.e productThumbnails? - If I have multiple images (previous question also applies) i.e images: v.array(v.id("_stareage")) when I delete I need to make sure I delete in both places (storage and in database) right? - Should I prefetch images in convex server side when I call i.e getProducts? i.e...

Cannot find module dataModel

error: ```ts utils/convex.ts:11:27 - error TS2307: Cannot find module '@/convex/_generated/dataModel' or its corresponding type declarations. 11 import { DataModel } from '@/convex/_generated/dataModel';...

Svelte: server side: call queries?

How can I call convex functions: queries, mutations, etc... from +page.server.ts from the load: PageServerLoad function? According to the docs, I need to add to +layout.svelte the following code: setupConvex(PUBLIC_CONVEX_URL); which is done. But as soon as I add const sessionJson = useQuery(api.auth.user.validateSession, { sessionId: sessionCookie }); into my load function I get the error:...
No description

Authentication in paginated query

How do I implement user authentication checks in paginated queries error: ```ts Type '{ success: boolean; message: string; }' is missing the following properties from type 'PaginationResult<any>': page, isDone, continueCursor...

Security policies blocking internal users?

We login as a lot of users to help them debug issues or take action on their behalf We noticed some queries tied to Convex don't load when we do this, making it seem like our website is broken. However, on different devices (where we login as multiple users less often), we don't see this issue. Is convex applying security policies to our internal accounts? Any way we can turn these off for us so we don't panic that something in prod has broken?...

Why I can't get current logged in user information

When I logged in using convex auth, auth and user tables updated, but can't get current authenticated user like this way const identity = await ctx.auth.getUserIdentity(); Also got this error...
No description

External API fetch advise

Hello, I'm using Convex folder for all my data-access layer now. I need to fetch some data from other APIs and they don't interact with Convex. I'm using Next.js. Is there any downside if I use an action in a 'use node' file for fetching data, or is better to use a next.js route instead?

Getting orgId from userIdentity does not work

I can't seem to apply my org ID to newly created resources. I'm not sure what I'm doing wrong : ```export const add = mutation({ args: { orgId: v.optional(v.string()), name: v.string(), category: v.string(),...

Why I can't get current user's information if I've already logged in

export const viewer = query({ args: {}, handler: async (ctx) => { const userId = await auth.getUserId(ctx); return userId !== null ? ctx.db.get(userId) : null;...