Creating an Extension
Get the latest developer guides on Fynd Partners Help
You're ready to create a new extension. You want to set up your development environment so that you can start coding. In this document, you'll use FDK CLI to create a Node.js embedded extension. FDK CLI generates starter code for building your extension and automates many common development tasks.
Why you should create an extension
You want your extension to embed in the Fynd Platform admin inside an iframe. Since this is your first time creating a Fynd Platform extension, you want to start with some boilerplate code that makes your programming experience easier and more efficient. By creating an embedded extension, you're able to add features to certain parts of Fynd Platform's user interface and online websites/sales channels. You'll also deliver the best seller experience because your extension will be closely integrated with Fynd Platform.
What you'll learn
After you've finished this document, you'll have accomplished the following:
- Set up your local development environment
- Generated starting code for building your extension
- Installed your extension on a development account
Requirements
- You've created a partner account and a development account.
- You understand the relation between Extensions and Fynd Platform.
- You've installed the Node.js v10+.
- You can use any frontend framework like VueJS, ReactJS, Angular, etc.
Preferred frontend framework is VueJS (v2.x).
How to get Partner access token
- Log in to your Fynd Partners
- Click on Manage
- Select your organization**
- Click on Access Token
- Click on Generate Token
- Copy the token
- Whoo! Now you are ready to develop an extension.
Steps to create an extension
Step 1: Install FDK CLI
npm install -g fdk-cli
Step 2: Create a new project
Step 3: Start a local development server
After your extension is created, you can work with it by navigating to your project directory and running npm run serve
to start a local development server.
FDK CLI uses ngrok/localtunnel to create a tunnel that allows your extension to be accessed using a unique HTTPS URL, which is mandatory when creating an extension.
Step 4: Install your extension on your development account
With the server running, open the URL that your terminal printed out in the previous step. When you open the URL, you're prompted to install the extension on your development account.
How to get API key and secret
- Log in to your Fynd Partners account
- Click on Manage
- Select your organization
- Click on Extensions
- Click on Create
- Select Private (These are available only to one seller and are not present on marketplaces)
- Select Public (These are available for all Fynd Platform sellers on the extension marketplace and are verified by our Fynd Platform team)
- Fill in the required details.
- Click Save
- It will create your extension configuration and you can take API key and secret from your Partners dashboard
- Whoo! Now you are ready to develop an extension.
Steps to register an extension
- Create a Fynd Partners account using the steps mentioned here
- Run npm install -g fdk-cli on your terminal
- Run fdk extension init - this will setup the development folder for extension and will register your extension
- Or you can use sample example project repo clone
How to execute Fynd Platform APIs
To call Fynd Platform APIs, utilize FDK - Fynd Development Kit. It has all exposed APIs embedded under functions with classes for specific services. All API uses OAuth2 to securely communicate with Fynd Platform services.
It mainly exposes two clients: ApplicationClient and PlaformClient.
PlatformClient - For calling Fynd Platform admin APIs
ApplicationClient - For calling user-facing APIs like products, cart, user address, checkout, etc.
For further examples and details, visit here.
Background tasks running under some consumer or webhook or under any queue can get platform client via a method getPlatformClient
. It will return instances of PlatformClient
as well. Here, FdkClient access_mode
should be offline. Cause such client can only access PlatformClient in background task.