# LINSERT

> Insert an element before or after another element in a list

## Arguments

<ParamField body="key" type="string" required>
    The key of the list.
</ParamField>



<ParamField body="direction" type="before | after" required>
    Whether to insert the element before or after pivot.
</ParamField>



<ParamField body="pivot" type="TValue" required>
    The element to insert before or after.
</ParamField>



<ParamField body="value" type="TValue" required>
    The element to insert.
</ParamField>

## Response

<ResponseField type="integer" required>
The list length after insertion, `0` when the list doesn't exist or `-1` when pivot was not found.
</ResponseField>

<RequestExample>
```ts Example
await redis.rpush("key", "a", "b", "c");
await redis.linsert("key", "before", "b", "x");
```
</RequestExample>
