[API reference](https://evolu.dev/docs/api-reference) › [@evolu/common](https://evolu.dev/docs/api-reference/common) › [Type](https://evolu.dev/docs/api-reference/common/Type) › IpAddress

```ts
const IpAddress: createType<
  "IpAddress",
  typeof String,
  Ipv4Address | Ipv6Address,
  IpAddressError
>(
  "IpAddress",
  String,
  (value) =>
    Ipv4Address.is(value) || Ipv6Address.is(value)
      ? ok(value)
      : err({ type: "IpAddress", value }),
  formatIpAddressError,
);
```

Defined in: [packages/common/src/Type.ts:9493](https://github.com/evoluhq/evolu/blob/bc4578a260dd15d5bbf94b83765ca05984d194cb/packages/common/src/Type.ts#L9493)

IP address of either family: an [Ipv4Address](https://evolu.dev/docs/api-reference/common/Type/variables/Ipv4Address) or a canonical
[Ipv6Address](https://evolu.dev/docs/api-reference/common/Type/variables/Ipv6Address).

Use IpAddress for addresses whose family is not known in advance, such as the
address of a client or peer. It fails with one [IpAddressError](https://evolu.dev/docs/api-reference/common/Type/interfaces/IpAddressError) instead
of a [UnionError](https://evolu.dev/docs/api-reference/common/Type/type-aliases/UnionError) that lists both families, and its Output narrows with
`Ipv4Address.is` or `Ipv6Address.is`.

Like its members, IpAddress does not normalize, so equal addresses are equal
strings. Use [IpAddressFromString](https://evolu.dev/docs/api-reference/common/Type/variables/IpAddressFromString) to convert other IPv6 spellings to
the canonical one. An IPv4-mapped address such as `::ffff:1.2.3.4` is an
Ipv6Address distinct from the Ipv4Address `1.2.3.4`, and dual-stack servers,
such as Node's by default, report IPv4 clients in the mapped form, so convert
addresses from different sources to one form before comparing them.

A non-string fails with the [String](https://evolu.dev/docs/api-reference/common/Type/variables/String) error.

### Example

```ts
import { assertEqual, assertErr, assertOk, IpAddress } from "@evolu/common";

assertOk(IpAddress.fromUnknown("192.168.1.1"), "192.168.1.1");
assertOk(IpAddress.fromUnknown("2001:db8::1"), "2001:db8::1");

const invalid = IpAddress.fromUnknown("2001:DB8::1");
assertErr(invalid, { type: "IpAddress", value: "2001:DB8::1" });
assertEqual(
  IpAddress.formatError(invalid.error),
  'The value "2001:DB8::1" is not a valid IPv4 address or canonical IPv6 address.',
);
```