Macro Config with Custom UI

Hi all,
How can I create the equivalent of MacroConfig using custom UI?
So far I created a config file but the system does not find it if it is not in the backend. And from there I’m not sure of how I can call useConfig (or equivalent) in the frontend. With the latest code I only get an undefined result.
Thanks

1 Like

Cross referencing…

2 Likes

Hi! Matteo, about useConfig() you can only use it in Forge’s UI Kit. If you wish to have the user’s configuration, then you should use the resolver in custom UI to call the forge backend api in order to get this configuration. The resolver in the backend usually return a context data when a request is made so in the context data you can find the configuration.

Below is a simple example:

In Custom UI use invoke to call the backend api

import { invoke } from "@forge/bridge";
 invoke("getUserConfiguration", {}).then(() => {
})

In forge backend receive context data

import Resolver from "@forge/resolver";
const resolver = new Resolver();
resolver.define("getUserConfiguration", async ({ payload, context }) => {
console.log('View context', context)
const userConfiguration = context.extension.config
console.log('userConfiguration', userConfiguration)
}
5 Likes