Integrating Node.js Libraries in Bubble Plugins: A Step-by-Step Guide

Integrating Node.js Libraries in Bubble Plugins: A Step-by-Step Guide

There are many instances when you may want to create a plugin based on an existing Node.js library. For example, you might want to integrate a Node.js "encryption" library like crypto-js, or integrate the "squids" library to generate YouTube-like IDs for given text.

But how do you add a Node.js library to the Bubble plugin editor?

Follow these steps:

Step 1:

Navigate to the "Action" section of the Bubble editor and create a new server-side action.

Step 2:

Check the box that says "This action uses the node modules."

Step 3:

Now, import the library into the action function using the "require" keyword.

As soon as you add the code to import the library and click outside of the "run_server" function, a warning will appear: "The deployment package for your action is out of date."

Click on this warning to rebuild the "package.json" file.

PS: Bubble does not support the "import" keyword for loading libraries.

If you still see the error "Library is not loaded," try different variations of the "require" keyword.

//try anyone 
const Sqids = require('sqids');
const Sqids = require('sqids').default;
const { Sqids } = require ('sqids');

That's all for this blog. Subscribe for more future updates. Thank you!

Follow me on twitter.

Checkout My Bubble Plugin Course - Use coupon code "THEBUBBLEGROUP" at checkout for 10% discount.

Did you find this article valuable?

Support Ankur Khandelwal by becoming a sponsor. Any amount is appreciated!