2

I am trying to integrate Auth0 authentication with my already made cordova mobile app. I set up the client and was following the quick start guide from auth0. The problem I am facing is that the guide does not seem to be suitable for a jQuery app because it uses require and in the end builds a module. I am not sure how to do this using jQuery, since all other js files I have are inside www/js folder and I do not know how to import node_modules inside my app.

var Auth0 = require('auth0-js');
var Auth0Cordova = require('@auth0/cordova');
....
....
module.exports = App;
  1. Can anyone tell me how can I do this without making much modification to my current app.
  2. If not possible to set this up with jQuery, what other ways are there to do this?
Arsalan Ahmed
  • 383
  • 2
  • 3
  • 14

1 Answers1

0

Not sure how you are trying to use jQuery. But the easiest option is simply to add the jQuery dependency to your js folder, and reference using the usual script header in index.html.

Couple of resources for points here and if wishing to use an npm module then see here. This is doing something similar, adding the needed js dependencies to the jsfolder, and then updating index.html to reference to those js dependencies.

Finally, it is possible to extend webpack to reference jQuery - see an answer I posted separately on that here.

arcseldon
  • 35,523
  • 17
  • 121
  • 125
  • maybe my question is not clear enough but the problem is not using jquery but how to use external modules in the front-end. I used browserify to generate one consolidated js file with all the dependencies. I put the require() in my main app.js So now my app.js contains my own code plus all the code from require() but what has happened is that my global variables in app.js have lost the global scope. I am not sure how to get back the global scope for my own variables. – Arsalan Ahmed Oct 06 '17 at 14:47
  • ok, this has nothing to do with Auth0, and more to do with your build system. Would google / search SOF for browserify related questions and global scope. – arcseldon Oct 06 '17 at 23:44