Most lightweight client I could use to connect to a meteor backend?

Hi there,

I’m looking to build a lightweight widget users can embed on their website with an iframe. I just learnt about webpack and its really amazing, I’m looking to build a form users can embed and submit to my meteor backend server

So i think the most important tool is I’ll need is the ability to connect to the server, call functions (to submit the form), and some way of differentiating each form with a key they’d add in the script. (How safe is using a key for authentication by the way?)

Im just looking for a really lightweight solution, i dont think I’ll be able to use webpack on a whole meteor/react built client

For a lightweight widget, I’d recommend sticking to basics.

Use WebApp.connectHandlers to setup a stock standard HTTP endpoint to submit your form or data to.
Then just send a plain old XMLHttpRequest to your server.

Even just adding a DDP client is a lot of weight, and you really don’t want to be the place with heavy widgets that other developers whine about :laughing:

1 Like

Try Asteroid: https://github.com/mondora/asteroid

Are there any examples of someone connecting this up? I dont quite understand how it gets the request

In my html I’ve added:
const xhr = new XMLHttpRequest();

xhr.open("POST", 'http://localhost:3000/request', true);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");

xhr.send('hello');

And then in the meteor server (which is on localhost:3000)

WebApp.connectHandlers.use('/request', (req, res, next) => {
  res.writeHead(200);
????????????????
  res.end('Post info' + ?????????);
});

Do I need to also import this: https://docs.meteor.com/api/http.html