How do I display NUI page?

Hello, I found this about NUI in docs https://docs.fivem.net/docs/scripting-manual/nui-development/full-screen-nui/

It shows how to add the page to the manifest and how to send messages to the page, but my question is… how do I display it in C# code? How do I invoke it to show when I want in the game, what is the function? Because I can’t find it…

Or once I put it in the manifest it is always visible in game while the resource is loaded? And I need to toggle visibility of elements from the HTML page?

The NUI page is loaded when the resource starts, and is always displayed. You’ll need to use CSS to control when it is displayed.

The C# version on that page is correct, but it assumes you are using a static import for the Natives. If you’re not doing that, then you’ll want to do something like:

API.SendNuiMessage(JsonConvert.SerializeObject(new { type = "SHOW_UI" }));

Your NUI page should listen for message event with that type, then display the content. If you need the C# script to close the nui page, send the same one but with a different type, and hide the content.

1 Like

Thank you a lot! I will do as you said.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.