Examples of admin page

Is there an example around on how to set up a Confluence admin page where you can configure one single value (for instance a string value)? I’ve been browsing the examples and haven’t been able to find a decent example for this very basic scenario.

Hi Jonas

We’ll need more information on what you mean by configuring a single value. You can store this value in the Forge hosted storage to retrieve later.

I’ve written a short example,

const App = () => {
  const [name, setName] = useState("...loading...");

  useEffect(async () => {
    setName(await storage.get("form_name"));
  }, []);

  const onSubmit = async (formData) => {
    setName(formData.name);
    await storage.set("form_name", formData.name);
  };

  return (
    <Fragment>
      <Text>{name}</Text>
      <Form onSubmit={onSubmit}>
        <TextField label="Name" name="name" />
      </Form>
    </Fragment>
  );
};

export const run = render(
  <GlobalSettings>
    <App />
  </GlobalSettings>
);

Let me know if this was not what you were looking for.