URL.username

The username property of the URL interface is a USVString containing the username specified before the domain name.

Note: This feature is available in Web Workers.

Syntax

const usernameString = url.username
url.username = newUsername

Value

A USVString.

Examples

const url = new URL('https://anonymous:flabada@developer.mozilla.org/docs/Web/API/URL/username');
console.log(url.username) // Logs "anonymous"

Specifications

Specification Status Comment
URL
The definition of 'username' in that specification.
Living Standard Initial definition.

Browser compatibility

DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
usernameChrome Full support 32Edge Full support 12Firefox Full support 26IE No support NoOpera Full support YesSafari Full support 10WebView Android Full support ≤37Chrome Android Full support 32Firefox Android Full support 26Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support 6.0

Legend

Full support
Full support
No support
No support

See also

  • The URL interface it belongs to.