# How to integrate Node JS SDK in Bubble Application

**URL:** <https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953>\
**Category:** App Organization\
**Created:** [November 13, 2023, 3:46pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953 "2023-11-13T15:46:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mghatiya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mghatiya/32/162800_2.png) [@mghatiya](https://forum.bubble.io/u/mghatiya)\
**Post date:** [November 13, 2023, 3:46pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/1 "2023-11-13T15:46:41Z")

</div>

Hi All,

I have following requirement, which after reading through forum I am unable to reach a good solution for. Would appreciate help and guidance in this matter.

I want to integrate a payment gateway (CCAvenue) in my application. The payment gateway has given NodeJS based SDK. The SDK has some Node JS files that handle some POST operations, some encryption of data etc.

I am trying to understand how do I incorporate this SDK in my application.

I have uploaded the files in SDK in my root directory.

I have tried these so far:

1. Running those Node JS files via `<script>` in html elements and via client side `Run Javascript` of Toolbox plugin. This one fails because JS files have some `require` statements that use some modules. And apparently Bubble does not allow these in frontend (or maybe they are not supposed to run in frontend in NodeJS)

2. Running these node JS files via `Server Script` of Toolbox plugin. This one fails because either `require` is not supported in these or because I am unable to figure out how do I use `require` and give reference to modules that I have uploaded to my root directory.

3. Creating plugin to include NodeJS modules. I am unable to figure out how do I use `require` and give reference to modules that I have uploaded to my root directory.

Could someone please guide on what is the right method and how exactly do I go about it. If you could put it down in simple English terms than heavy tech words, it would be of great help.

Thanks,  
Mukesh

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [November 13, 2023, 4:08pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/2 "2023-11-13T16:08:59Z")

</div>

A nodejs SDK is meant to run on the server.  
You should create a plugin with a server side action. Specify the sdk as dependency in the package.json section of the editor and then require the package in your action code.  
Installing the SDK as a dependency has nothing to do with uploading files in the root directory. Bubble will fetch the dependency from the registry and bundle it with your action code.  
Since you mention encryption I suppose you have some sort of secret key. Be sure to store it as a **private** key in the global settings of the plugin so that it will be safely stored for server only use and it can be specified by the application using the plugin.

---

<div class="post-metadata">

**Author:** ![mghatiya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mghatiya/32/162800_2.png) [@mghatiya](https://forum.bubble.io/u/mghatiya)\
**Post date:** [November 13, 2023, 4:17pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/3 "2023-11-13T16:17:59Z")

</div>

Thanks @dorilama for the reply.

How do I specify SDK as dependency in package.json? I think I am aware of how do I add a standard module as dependency in plugin (I read that just using `require(modulename)` will add the dependency in package.json automatically. Otherwise I can specify it in the `dependencies` section). However, the SDK that I have got was a zip file. When I unzipped it, it had a few .js files. I have uploaded those .js files to my root folder.

Some of those .js files are “request handler” type which expect some data coming to them via `POST` and some are exposed as `modules` and are used in other files via `require` For example one statement in one of the files is like this:

```auto
var http = require('http'),
    fs = require('fs'),
    ccav = require('./ccavutil.js'),
    qs = require('querystring');

```

And on this I get error that it can’t figure out how to get `./ccavutil.js`. So I suppose I need a way to be able to access those modules in some different way. I am not aware of how do I do that.

Also, the `ccavutil.js` in itself has `require('crypto')` . I do not know if that will work as it is or do I need to do something special.

Also the handler file has code written such that it assumes it has got some parameters in `POST` request. Can that be put in Server Side Script in the plugin as it is?

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [November 13, 2023, 4:27pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/4 "2023-11-13T16:27:59Z")

</div>

Unfortunately bubble plugins are a bit limited. With local files you need to bundle everything in a big file that you paste in the action code before your own logic. It’s not ideal and can be tricky if you are not used to developing in js but it’s probably the quickest way to solve this.  
An alternative is to publish the sdk as a public library. I don’t think that bubble can handle private registries or repositories, you may want to check that with support.  
`http`, `fs`, `querystring`, `crypto` are modules provided with nodejs, you don’t need to do anything for that.

---

<div class="post-metadata">

**Author:** ![mghatiya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mghatiya/32/162800_2.png) [@mghatiya](https://forum.bubble.io/u/mghatiya)\
**Post date:** [November 13, 2023, 4:31pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/5 "2023-11-13T16:31:22Z")

</div>

Thanks again.

> [@dorilama](#):
>
> you need to bundle everything in a big file that you paste in the action code before your own logic

Yes, that 's what I had started on a couple of hours ago as I was not able to find any solution. Still working on it though.

> [@dorilama](#):
>
> An alternative is to publish the sdk as a public library

How do I do that? When I do that, will I be able to access module by just `require(modulename)`? or will I have to specify that in some path somewhere?

---

<div class="post-metadata">

**Author:** ![mjohnson34](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mjohnson34/32/96534_2.png) [@mjohnson34](https://forum.bubble.io/u/mjohnson34)\
**Post date:** [November 13, 2023, 4:33pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/7 "2023-11-13T16:33:05Z")

</div>

You would be better probably running this code elsewhere maybe on replit or another service.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/dorilama/32/226878_2.png) [@dorilama](https://forum.bubble.io/u/dorilama)\
**Post date:** [November 13, 2023, 4:34pm UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/8 "2023-11-13T16:34:36Z")

</div>

> **[Creating and publishing unscoped public packages | npm Docs](https://docs.npmjs.com/creating-and-publishing-unscoped-public-packages/)**
>
> Documentation for the npm registry, website, and command-line interface

---

<div class="post-metadata">

**Author:** ![mghatiya](https://sea1.discourse-cdn.com/bubble/user_avatar/forum.bubble.io/mghatiya/32/162800_2.png) [@mghatiya](https://forum.bubble.io/u/mghatiya)\
**Post date:** [November 14, 2023, 6:50am UTC](https://forum.bubble.io/t/how-to-integrate-node-js-sdk-in-bubble-application/292953/9 "2023-11-14T06:50:43Z")

</div>

Thanks @dorilama @mjohnson34 for your inputs. For now I have put the SDK in one file itself and that seems to be working. Though I am yet to try it out fully from different angles. But looks like it should work.
