---
schema_version: "1"
id: 8cc0a95059c664dc8a6423ef22d64f6594046f79e29e369e8fbcf79902651b23
title: Create a Redis Client in Node.js
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/salesforce-functions/functions/guide/dev-guide/heroku-redis-js.md
canonical_url: https://developer.salesforce.com/docs/platform/functions/guide/heroku-redis-js.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 72d7fc1f65381f04db61c7ec90f8f8c16e96f2a9f4acbce7303dc4da97110076
products:
  - Salesforce Functions
---
# Create a Redis Client in Node.js

For Salesforce Functions written in Node.js, use the [node-redis](https://www.npmjs.com/package/redis) (redis) package to access your Redis datastore. Access the `REDIS_URL` environment variable with `process.env` to create a Redis client instance.

```javascript
async function redisConnect() {
  const REDIS_URL = process.env.REDIS_URL;
  if (!REDIS_URL) {
    throw new Error("REDIS_URL is not set");
  }
  // Connect to Redis
  const redisClient = createClient({
    url: REDIS_URL,
    socket: {
      tls: true,
      rejectUnauthorized: false,
    },
  });

  await redisClient.connect();
  return redisClient;
}
```
