Creating a Custom Component React Plugin


I was reading through the documentation to create a component plugin here: 

It mentions that you can use the token for the javascript api, and that it will be replaced when the plugin is deployed.  For the case of a react component I would want to do a production build prior to deployment.  In order to run the build command I would need to access to the api so that I could import it and use the associated methods in the code.  How would I add the Appian.Component class as a node module or dependency?


  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    Hey , if I'm not wrong, what you could do is to add the script to your index.html entry file for your custom component. Once deployed to Appian, the Appian.Component object will be available in the global scope and you would be able to access it anywhere within your React application.

  • You could do it that way, but if that was the case you would not be developing on a webpack dev server / or min the code with a production build.  The build would happen before the component is deployed to Appian, so the build would fail.  

  • 0
    Certified Associate Developer
    in reply to chanceb

    Actually that's been the way we've been deploying our custom component to our Appian environment.

    What we are doing currently is to put the script within the index entry file so that it would get loaded successfully when deployed to Appian. This is after we have ran the webpack build and it returns us our index_bundle.js file.

    When we run it on webpack dev server however, the loading of this script will fail, however we have another module which handles a backend call to our local server to call third-party APIs.

    So we're building an extra module which would be needed when we do development and testing on our local environment, as opposed to when you have the Appian.Component when the custom component has been deployed to your Appian environment.