Kinde TypeScript type in Next.js middleware
Hi,
With Next.js 14 and TypeScript, may I know how can I specify the type for
req
so that it recognizes req.kindeAuth
,
Is there a type provided by Kinde?1 Reply
Hi @TJ,
In the Kinde Next.js SDK, the
req
object is an instance of the Next.js NextApiRequest
type, which is extended with a kindeAuth
property.
To specify the type for req
in TypeScript, you can create a new type that extends NextApiRequest
and includes kindeAuth
.
Here's an example:
In this example, KindeRequest
is a new type that includes all properties of NextApiRequest
and an additional kindeAuth
property. You can replace any with the actual type of kindeAuth
if it's known.
Please note that the type of kindeAuth
isn't explicitly defined in the Kinde SDK, so you might need to adjust the type based on your application's needs.
We will add in proper types to the NextJS SDK very soon.
Hope this helps! Let me know if you have any other questions.