Kanvas provides a robust set of GraphQL APIs designed to cover the essential features of headless applications:
- 🔐 Authentication: Easily manage user authentication.
- 🏢 Multi-tenancy: Seamlessly handle multiple tenants.
- 👥 Customer Management (CRM): Manage customers, leads, and more.
- 📦 Inventory Management: Track and manage products and stock levels.
- 🤝 Social Interactions: Enable user interactions like follows, likes, and comments.
- 🔄 Workflows: Automate business processes with customizable workflows.
By taking care of these critical backend functionalities, Kanvas allows you to focus on building your app's unique business logic without reinventing the wheel.
This guide covers the following steps:
- Installing the Kanvas SDK
- Setting up and configuring the SDK in your project
- Basic examples of how to use the SDK
Let’s get started!
- Node.js version 12 or higher.
- KANVAS APP KEY: You need a Kanvas App Key to use the SDK. Currently, Kanvas is in closed beta. To join, sign up for our newsletter at kanvas.dev.
Alternatively, you can run your own Kanvas ecosystem by cloning the Kanvas Ecosystem API and following the provided setup instructions.
To install the SDK in your project, run one of the following commands:
npm install @kanvas/core --save
yarn add @kanvas/core
Once the SDK is installed, you'll need to configure it with your GraphQL API URL and App Key, which can be obtained from your Kanvas dashboard.
import KanvasCore, { genericAuthMiddleware } from '@kanvas/core';
function App() {
const Kanvas = new KanvasCore({
url: '{{GRAPHQL_URL}}', // Your Kanvas GraphQL API URL
key: '{{KEY}}', // Your Kanvas App Key
middlewares: [
genericAuthMiddleware(() => {
return Promise.resolve(
localStorage.getItem("token") // Token handling for authentication
);
}),
],
});
}
This is for when you want to access the Kanvas API as the super admin.
import KanvasCore, { genericAuthMiddleware } from '@kanvas/core';
function App() {
const Kanvas = new KanvasCore({
url: '{{GRAPHQL_URL}}', // Your Kanvas GraphQL API URL
key: '{{KEY}}', // Your Kanvas App Key
adminKey: '{{ADMIN_KEY}}', // Your Kanvas Admin Key
middlewares: [
genericAuthMiddleware(() => {
return Promise.resolve(
localStorage.getItem("token")
);
}),
],
});
}
This basic setup initializes the SDK and configures an authentication middleware to automatically attach a user token to API requests.
When integrating with your application in Kanvas, it’s important to understand the difference between Token Authentication and Super Admin API Access:
Client APIs and SDKs are designed for building user-facing applications, such as websites or mobile apps. With Token Authentication, users can only access the resources in your app that they have been granted permission to use, based on their roles and assigned permissions.
This ensures that users interact with your app in a secure and controlled way, with access limits defined by the application’s permissions structure.
The Super Admin API is intended for backend or server-side integrations with your app in Kanvas, providing full access to all resources. Unlike Token Authentication, the Super Admin API ignores user-specific permissions and instead operates based on the API key’s scope, giving full administrative control over the app.
While the Super Admin API grants complete control over your app, it should never be used on the frontend. Its purpose is strictly for backend operations, and in the future, you’ll be able to scope API keys to allow more granular control over what parts of the app are accessible.
Now that you've installed and configured the SDK, you're ready to start integrating Kanvas into your app. Head over to our user management guide to learn how to authenticate users in your application.