[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) › prefixed

```ts
function prefixed<Prefix>(
  prefix: Prefix & ValidateLiteral<Prefix>,
): <T>(
  type: T & ValidateOutput<T> & string extends T["Input"]
    ? unknown
    : "⛔ Type error: Prefixed Type Input must accept every string.",
) => PrefixedType<Prefix, T>;
```

Defined in: [packages/common/src/Type.ts:6722](https://github.com/evoluhq/evolu/blob/dd96d79f1dbe9a49fa12ce8e0aa7d3d0177795ca/packages/common/src/Type.ts#L6722)

Decodes a prefixed string with another [Type](https://evolu.dev/docs/api-reference/common/Type/interfaces/Type) and restores the prefix
when encoding.

Uses [startsWith](https://evolu.dev/docs/api-reference/common/Type/functions/startsWith) to validate an exact, case-sensitive prefix before
removing one occurrence. The wrapped Type validates and decodes the suffix;
its constraints apply to the suffix, and its Output is preserved. Encoding
prepends the prefix to the wrapped Type's canonical string representation. An
empty prefix leaves that representation unchanged.

The prefix must be one concrete string literal. The wrapped Type must accept
a string Input and encode to strings; its Output can have another type, as
with [PortFromString](https://evolu.dev/docs/api-reference/common/Type/variables/PortFromString).

### Example

```ts
import {
  assertEqual,
  assertErr,
  assertOk,
  assertType,
  ConstantCaseIdentifier,
  prefixed,
  PortFromString,
  type Port,
} from "@evolu/common";

const EnvName = prefixed("APP_")(ConstantCaseIdentifier);

const name = EnvName.fromUnknown("APP_PORT");
assertOk(name, "PORT");
assertType<typeof name.value, ConstantCaseIdentifier>();

assertEqual(EnvName.to(name.value), "APP_PORT");

assertErr(EnvName.fromUnknown("OTHER_PORT"));
assertErr(EnvName.fromUnknown("APP_port"));

const PortSetting = prefixed("port:")(PortFromString);

const port = PortSetting.fromUnknown("port:04000");
assertOk(port, 4000);
assertType<typeof port.value, Port>();

assertEqual(PortSetting.to(port.value), "port:4000");
```