Custom widget accessing connected boards to dashboard

Hi community,

I’m building a custom widget with React for use in Monday.com. As it’s a widget, it will appear on a dashboard. Since dashboards can be connected to other boards, I want my widget to be able to access the specific boards that the dashboard (on which it appears) is connected to. In other words, is there is a way for a custom widget to access the board IDs of specifically the board(s) the dashboard is connected to?

Thank you so much for your help!

Listen to the context. The boardIds should be found there and then you can query the boards using the api.

Hi David,

Thank you for the response! I did actually try the monday.listen(“context”, …) function, but I got the error: “TypeError: monday.listen is not a function”. Do you have any tips or a working example?

Thank you!


import mondaySdk from "monday-sdk-js";

// …

const monday = mondaySdk();

monday.listen("context", res => {
  console.log(res.data);
  // do Something
})

Thank you! It works. I think I just had it in the wrong place in my program. I appreciate the help.

One last question that’s not fully related but has been bugging me: when I run “mapps code:push” to push my local changes to Monday.com and deploy the app, it takes much longer than it’s supposed to (~360 seconds instead of 30-60). I’m wondering if that’s because it’s trying to push my node_modules folder too – is there a way to prevent that? Or a way to speed up this process in general so that it doesn’t take five or six minutes every time I make a change locally until I can test on Monday.com?

Thank you.

@ec23 My CI/CD jobs are running at around 5 minutes to spin up a system, build and deploy to monday-code.

This is building from scratch on a clean node:20 image:

In general, what the deploy does (if you haven’t changed things) is take a zip of your root directory, upload it, and then try to run that.

The first run ever is usually around 15 mins, but I’d expect between 1 & 3 mins if you’re just pushing code from your dev machine.

@dipro can probably answer this better.

Okay, and there’s no way to speed that up? (I haven’t changed any of the deploy settings.)

Also, where should I put the monday.listen() call? I’ve tried including it both outside and inside my React useEffect() hook and either way it seems to be running incredibly frequently because, to test, I have it log the res.data to the console in the callback function, and it prints hundreds of thousands of times… and can crash the tab :sweat_smile: . Is that normal/what should I change?

Thank you.

@ec23 there should be some code examples somewhere for that.

I think my old React code had it in componentDidMount so likely useEffect would be the place.

I’m not now using react, so my code examples would be wrong for you.

Also, a nice trick will be to check if the context has changed since last time is was sent, that way it wouldn’t get updated every time it’s sent.