I am trying to create a dynamic Confluence page based on a GET request parameter

I am trying to create a dynamic Confluence page based on a GET request parameter (e.g., ?id=). On the client side, I am using the following JavaScript code:

const urlParams = new URLSearchParams(window.location.search);
console.log(urlParams.get(‘id’)); // Expected to retrieve ‘id’ parameter

However, urlParams returns an empty object, and I cannot retrieve the query parameter.

Is there any restriction in Confluence that prevents accessing query parameters from window.location.search, or is there an alternative approach to achieve this?
My goal is to dynamically populate the page based on the id parameter from the URL.

When using UI Kit you can use the useProductContext hook and when using Custom UI the view. getContext() method to get the current context. In both cases the page/content ID should be included somewhere under the extension field.
I’ve never needed the page ID myself so I don’t know the name, but it’s probably pageId or contentId.

Hey, thanks for the answer, but this isn’t about obtaining the page ID where the program is running. I want to get a query from the user (for example: ?movie_type=Comedy&min_rating=8). Something like that, to get a custom query. The program is not running within a page; it’s a global page.

Hey @VladimirSumilin,

I think you’ll find the answer in this earlier post How to query page url value from forge UI KIT - #4 by danielwinterw

There’s further discussion around accessing the URL parameters in the post, How to get the URL of a Forge app in Jira? and an issue was raised to request URL parameters be provided in the context parameters (see FRGE-706 ) which i think would solve your problem - so you might want to add a comment about your use case there to help the team prioritise the issue in the future.

I hope this explains.

Mel