@icomedias/hybridforms-js
TypeScript icon, indicating that this package has built-in type declarations

1.2.1 • Public • Published

Isomorphic TS/JS Lib (@icomedias/hybridforms-js)

Build status NPM Version standard-readme compliant

A Typescript/Javascript isomorphic library, for use in HybridForms forms and Node.js.

Typedoc: https://icodeveloper.github.io/hybridforms-js/

Table of Contents

Install

  • Node.js 18+ is recommended.

NPM

To install via NPM:

npm install @icomedias/hybridforms-js

Development

To install locally (for development):

git clone https://github.com/IcoDeveloper/hybridforms-js.git
cd hybridforms-js
npm install

Usage

First of all, you need to install the library:

npm install @icomedias/hybridforms-js

Then you're able to import the library and establish the connection with the database:

import { createClient } from '@icomedias/hybridforms-js'

// Create a single HybridForms client for interacting with the API
const hybridforms = createClient({
    baseUrl: 'example.hybridforms.com',
    clientId: '1',
    user: 'test@test.com',
    password: '123456'
})

UMD

You can now use plain <script>s to import hybridforms-js, like:

<script src="hybridforms.min.js"></script>

Then you can use it from a global HybridFormsJS variable:

<script>
    const { createClient } = HybridFormsJS
    const hybridforms = createClient({
        baseUrl: 'example.hybridforms.com',
        clientId: '1',
        user: 'test@test.com',
        password: '123456'
    })

    console.log('HybridForms Instance: ', hybridforms)
  // ...
</script>

Custom xhr implementation

hybridforms-js uses the node-fetch library to make HTTP requests, but an alternative xhr implementation can be provided as an option. This is necessary in HybridForms forms where an authentication is already available:

<script data-hf-src="hybridforms.min.js"></script>
const { createClient } = HybridFormsJS
// Provide a custom `xhr` implementation as an option
const hybridforms = createClient({
    baseUrl: 'example.hybridforms.com',
    clientId: '1',
    xhr: HybridForms.API.XHR.request
})

Contribute

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

License

MIT License © 2023 icomedias GmbH.

Package Sidebar

Install

npm i @icomedias/hybridforms-js

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

252 kB

Total Files

101

Last publish

Collaborators

  • icodeveloper