---
title: user
framework: foundation
role: symbol
role_heading: Instance Property
path: foundation/nsurlcomponents/user
---

# user

The username URL subcomponent, or nil if not present.

## Declaration

```swift
var user: String? { get set }
```

## Discussion

Discussion For example, in the URL http://username:password@www.example.com/index.html, the user is username.

## See Also

### Accessing components in native format

- [fragment](foundation/nsurlcomponents/fragment.md)
- [host](foundation/nsurlcomponents/host.md)
- [encodedHost](foundation/nsurlcomponents/encodedhost.md)
- [password](foundation/nsurlcomponents/password.md)
- [path](foundation/nsurlcomponents/path.md)
- [port](foundation/nsurlcomponents/port.md)
- [query](foundation/nsurlcomponents/query.md)
- [queryItems](foundation/nsurlcomponents/queryitems.md)
- [scheme](foundation/nsurlcomponents/scheme.md)
