---
title: "SlugStrategy"
isDefaultIndex: false
generated: true
---
<!-- This file was generated from the Vendure source. Do not modify. Instead, re-run the "docs:build" script -->
import MemberInfo from '@site/src/components/MemberInfo';
import GenerationInfo from '@site/src/components/GenerationInfo';
import MemberDescription from '@site/src/components/MemberDescription';


## SlugStrategy

<GenerationInfo sourceFile="packages/core/src/config/entity/slug-strategy.ts" sourceLine="44" packageName="@vendure/core" since="3.5.0" />

Defines the strategy for generating slugs from input strings.
Slugs are URL-friendly versions of text that are commonly used for
entity identifiers in URLs.

*Example*

```ts
export class CustomSlugStrategy implements SlugStrategy {
  generate(ctx: RequestContext, params: SlugGenerateParams): string {
    return params.value
      .toLowerCase()
      .replace(/[^a-z0-9]+/g, '-')
      .replace(/^-+|-+$/g, '');
  }
}
```

```ts title="Signature"
interface SlugStrategy extends InjectableStrategy {
    generate(ctx: RequestContext, params: SlugGenerateParams): string | Promise<string>;
}
```
* Extends: <code><a href='/reference/typescript-api/common/injectable-strategy#injectablestrategy'>InjectableStrategy</a></code>



<div className="members-wrapper">

### generate

<MemberInfo kind="method" type={`(ctx: <a href='/reference/typescript-api/request/request-context#requestcontext'>RequestContext</a>, params: SlugGenerateParams) => string | Promise&#60;string&#62;`}   />

Generates a slug from the input string.


</div>
