Follow

Do you have samples for the Web SDK and how can I run them?

Yes, we do. If you want to immediately try out the performance of our barcode scanner, please try out our demo app

The below guide concerns the recent WebSDK 6.x release. If you're still using WebSDK 5.x, please go here

Our samples highlight simple usage of our SDK to provide barcode scanning in the browser, if you want to see how to run any of our samples you can follow this guide:

  1. Set the license key. To do this, sign in to your Scandit account and find your license key at ssl.scandit.com/licenses.

Once you have the license key, add it to the sample that you’d like to run:

await Scandit.configure("YOUR_LICENSE_KEY_HERE");
  1. Install the dependencies:

npm install
  1. Run the sample:

npm start
    1. Open http://localhost:8888 with your browser.

    2. You can use an SSH tunnel to access the running sample from another device via the internet. To do so, you can install ngrok <https://ngrok.com/> and create a tunnel to the running sample.

      Make sure you use the HTTPS tunnel because most of the browsers will deny permission to access the camera in non-secure contexts.

      ngrok http 8888

 

For accessing all the samples available for our webSDK you can follow this link: https://github.com/Scandit/datacapture-web-samples

 

WebSDK 5.x (Legacy)

If you want to see how our JavaScript library can be integrated, our samples highlight simple usage of our JavaScript API to provide barcode scanning in the browser.

1. To use our samples shipped with the SDK, you first need to install our SDK and http-server npm package (with npm or yarn commands).

  • With npm commands:
    // navigate to the project's directory
    > cd path/to/directory
    // initialize the npm project
    > npm init
    // download the web sdk
    > npm install scandit-sdk --save
    // install globally the http-server package

    > npm install http-server -g
  • With yarn commands:
    // navigate to the project's directory
    > cd path/to/directory
    // download the web sdk
    > yarn add scandit-sdk
    // install globally the http-server package

    > yarn global add http-server

     

    2. In your project's directory now appeared a few files. Go to node_modules > scandit-sdk and add your license key (you will find it on ssl.scandit.com/licenses) inside the samples (example.html and example_background.html). The code snippet you need to insert the key into is: 

    ScanditSDK.configure("YOUR_LICENSE_KEY_IS_NEEDED_HERE",{
      engineLocation:"build"});


    3. Next, you can simply go to the samples directory and run the installed package:

    // go to the samples directory
    > cd node_modules/scandit-sdk
    // run the new package
    http-server

    4. You can now open your browser and access the samples on the following URLs:

    5. For more samples, using not only JavaScript but also React and Angular technology, please check out our Github repository for samples for the Web SDK:

    https://github.com/Scandit/barcodescanner-sdk-for-web-samples.

Was this article helpful?
0 out of 2 found this helpful
Have more questions? Submit a request