Using Kinde without an SDK
SDKs and APIs
The Nuxt Kinde module allows developers to integrate Kinde authentication into their existing Nuxt projects.
For new projects, you can also find our Starter Kit on GitHub.
Nuxt 3+.
If you haven’t already got a Kinde account, register for free here (no credit card required). Registering gives you a Kinde domain, which you need to get started, e.g. yourapp.kinde.com.
Install the @nuxtjs/kinde
dependency using your package manager of choice.
Add @nuxtjs/kinde
to the modules section of your nuxt.config.ts
.
Add the following values to your .env
file. If you don’t have one create a file in the root of your project.
Replace http://localhost:3000
with the URL where your project is running.
For your app to work with Kinde, you need to set callback and logout redirect URLs.
Replace the values you see in <code brackets>
with your own values.
<http://localhost:3000>/api/callback>
<http://localhost:3000>
Tip: Make sure there are no hidden spaces in URLs and remove the ‘/’ backslash at the end.
If you would like to use different Environments as part of your development process, you will need to add them within your Kinde business first. You will also need to add the Environment subdomain to the code block above.
Kinde supports an easy to implement login / register flow.
Use the button examples below to redirect your users to Kinde, where they authenticate before being redirected back to your site.
After your user has authenticated they will be redirected to the URL set in your .env
file
It’s likely that your project will have both pages that are publicly available and private ones which should only be available to logged in users. Add this code snippet to pages you would like to protect.
Once a user has been verified, your project or app returns the JWT token with an array of permissions for that user. Configure your app to read permissions and unlock the respective functions.
Set permissions in your Kinde account. Here’s an example set of permissions.
We provide helper functions to more easily access the permissions claim, example of usage:
When a user signs in, the access token your project/application receives contains a custom claim called feature_flags
which is an object detailing the feature flags for that user.
You can set feature flags in your Kinde account. Here’s an example.
We have provided a helper to grab any feature flag. For example:
You can find specific string
, boolean
and integer
helpers in the TypeScript SDK docs.
You can check if a user is logged in with the $auth.loggedIn
context.
This is implemented in much the same way as signing up or signing in.
Register your first user by signing up yourself. You’ll see your newly registered user on the Users page in Kinde.
User details can be found on the $auth.user
object
To have a new organization created within your project, you can use the register api end point and pass is_create_org="true"
. This will redirect the user to Kinde and create an organization with them as a member.
When a user signs up or in to an organization, the org_code
needs to be passed with the request. The org_code
refers to the one created automatically in Kinde when the organization was created.
Here’s an helper function for registering or signing in below using org_0e9f496742ae
as an example:
Because a user can belong to multiple organizations, and because they may have different permissions for the different organizations, we will pass you both the org_code
and permissions
back in the token when authentication is initiated like this.
To check your configuration, the SDK exposes an endpoint with your settings.
/api/health
Note: The client secret will indicate only if the secret is set or not set correctly.
To enable set the debug property within the Kinde config.
To use our management API please see @kinde/management-api-js
If you need help using Kinde, please contact us at support@kinde.com or join the Kinde community on Discord or Slack.