Welcome to the Kinde community

Updated last year

Integration with Convex Custom Auth

I am creating a notion-like app with Nextjs. I am using Convex as my backend. I haven't figured out how to integrate it with Kinde as my custom auth provider. Has someone been able to integrate Kinde auth with Convex. If there is a way, could someone help me?
1
V
N
U
13 comments
Hey! I'm unfamiliar with Convex as a whole, but can certainly help you. Where are you getting stuck?
You're using NextJS as the front end; so this would be a good resource! https://github.com/kinde-oss/kinde-auth-nextjs
Here seems to be a guide on how to get it set up: https://docs.convex.dev/auth/custom-auth
Plain Text
"use client";

import { ClerkProvider, useAuth } from "@clerk/clerk-react";
import { ConvexReactClient, ConvexProviderWithAuth } from "convex/react";
import { ReactNode } from "react";

const convex = new ConvexReactClient(process.env.NEXT_PUBLIC_CONVEX_URL!);

export const ConvexClientProvider = ({ children }: { children: ReactNode }) => {
  return (
    <ClerkProvider
      publishableKey={process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY!}
    >
      <ConvexProviderWithAuth useAuth={useAuth} client={convex}>
        {children}
      </ConvexProviderWithAuth>
    </ClerkProvider>
  );
};

Here is an example with clerk.
Kinde auth SDK for next js does not have a client provider. Also, when I tried importing {useKindeAuth} from "@kinde-oss/kinde-auth-nextjs" for the ConvexProviderWithAuth useAuth Prop, I got a type error when I try that.
Hey! Let me take a look and see if I can integrate this from my side and will share the results. It should be straightforward, we will write a guide on this as well to help further people once we get this across.

I believe we currently are experiencing a bug with the SDK which should be resolved intermittently then we can take a look!
Hey @VKinde, I tried to create a custom auth for convex. https://github.com/umuthopeyildirim/kindeconvex
But it's not working since convex cant find the auth provider.
Attachment
Screenshot_2023-11-09_at_10.00.26_AM.png
Hey! I'm still looking into this and seeing if we can implement a workaround for the auth provider context to get the auth details directly. i'll let you know when I have something tangible or if it will be a wasted effort.
I reached out to Convex team and it seems like Kinde is missing "aud" details in JWT token. https://discord.com/channels/1019350475847499849/1172125658823020564
I made the react version work πŸ™‚ Here is also react version;
https://github.com/umuthopeyildirim/react-kinde-convex/
Sure thank you.
Hey! Have you checked the above repo that a fellow community member has provided? Btw amazing work there πŸ”₯ @Umut (Hope) YILDIRIM

The aud token is there, it just returns an empty array when unspecified which I believe is causing the whole issue.
When you make a request without specifying the audience, we return the aud claim as an empty array []. It seems like some libraries basically consider this to mean more or less that it is not valid for any audiences
Thanks! I also opened a PR for it https://github.com/get-convex/convex-js/pull/5 if kinde and convex prepares a guide or tutorial that would be amazing πŸ”₯
Hi, have you find an easy way to connect kinde with convex or not?
I'm waiting to hear back, but it looks like this will have to be supported by an external package. This will most likely look like (or just be) the above one that umuthopeyildrium created above as this would have to be community supported for the time being, so will be offered in a "as-is" state.

I'll have more details in the coming days
Add a reply
Sign up and join the conversation on Discord