# redis-url

> Connect to redis using a fully-qualified URL

Latest version **1.2.1** (published 2015-07-24) · 0 weekly downloads

## Install

```sh
npm install redis-url
pnpm add redis-url
yarn add redis-url
bun add redis-url
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2015-07-24 |
| First published | 2011-08-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 60 |
| Author | David Dollar |
| Maintainers | ddollar, zeke |

## Links

- npm: https://www.npmjs.com/package/redis-url
- Repository: https://github.com/ddollar/redis-url
- Homepage: https://github.com/ddollar/redis-url#readme
- Issues: https://github.com/ddollar/redis-url/issues
- npm.io page: https://npm.io/package/redis-url

## Dependencies (1)

- [redis](https://npm.io/package/redis.md) >= 0.0.1

## Recent versions

- 1.2.1 (latest) — 2015-07-24
- 1.2.0 — 2015-04-07
- 1.1.0 — 2015-03-20
- 1.0.0 — 2015-03-20
- 0.3.1 — 2014-11-07
- 0.3.0 — 2014-11-07
- 0.2.0 — 2013-09-05
- 0.1.0 — 2011-09-19
- 0.0.1 — 2011-08-16

## README

# redis-url

Connect to redis using a fully-qualified URL.

## Usage

```js
// Defaults to process.env.REDIS_URL or redis://localhost:6379
var redis = require('redis-url').connect();

// Or you can specify a URL
var redis = require('redis-url').connect(process.env.SOMEREDIS_URL);
```

The module also exposes a `parse` function you can use to extract parts of a
redis URL. It behaves similarly to [node's url.parse](http://goo.gl/o8pXyf),
but adds two extra properties: `password` and `database`.

This feature comes in handy when using redis-backed tools that don't accept
a fully-qualified URL, such as Hapi's
[catbox-redis](https://github.com/hapijs/catbox-redis#readme).  

```js
require("redis-url").parse('redis://:secrets@example.com:1234/9?foo=bar&baz=qux')

{
  protocol: 'redis:',
  slashes: true,
  auth: ':secrets',
  host: 'example.com:1234',
  port: '1234',
  hostname: 'example.com',
  hash: null,
  search: '?foo=bar&baz=qux',
  query: { foo: 'bar', baz: 'qux' },
  pathname: '/9',
  path: '9',
  href: 'redis://:secrets@example.com:1234/9?foo=bar&baz=qux',
  password: 'secrets',
  database: '9'
}
```

## URL format

```
redis://[:password@]host[:port][/db-number][?option=value]
```

**db-number** is a non-negative decimal integer

See [the IANA registration](http://www.iana.org/assignments/uri-schemes/prov/redis) for more details.

## Test

```
redis-server&
npm install
npm test
```

## License

MIT

---
_Source: https://npm.io/package/redis-url · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
