This is a sample implementation of the Corbado React package and Corbado Node SDK being integrated into a web application built with Next.js.
Please see the full blog post to understand the detailed steps needed to integrate passkeys into Next.js apps.
app/auth/page.tsx: the file where the React Auth component is usedapp/profile/page.tsx: displays user information if the user has successfully authenticated (rendered on the server)app/user-data/route.ts: api route that checks the users authentication state using the Corbado Node SDKapp/page.tsx: client rendered page that accesses data from the above mentioned route.env.local: add relevant environment variables that you can obtain from Corbado developer panel
Please follow the steps in Getting started to create and configure a project in the Corbado developer panel.
You need to have Node and npm installed to run it.
Use the values you obtained in Prerequisites to configure the following variables inside an .env.local
file you create in the root folder of this project:
NEXT_PUBLIC_CORBADO_PROJECT_ID=<YOUR PROJECT ID>
CORBADO_API_SECRET=<YOUR API SECRET>Run
npm ito install all dependencies.
Finally, you can run the project locally with
npm run devYou can also run the project in a docker container using the provided docker-compose.yml file.
docker-compose up --build