nodemcu identify on network

Sorry if this is a simple q but I have found no answers on google.

Most of the devices on my network will identify themselves on my LAN, so when I run a network scanner I can see them by name.

So for example this PC is called RYZEN5

However gadgets I have built with the NODEMCU just seem to get an ip address.

Is there a way I can assign a name to them that will be picked up by the router?

Include mDNS and then use .hostname to set the name you want displayed.

#include <ESP8266mDNS.h>

WiFi.hostname("myDeviceName");                      // Set WiFi name to match device name