# react-next-internal-link

> A helper component to easily create internal, relative links from absolute urls in your NextJS React apps.

Latest version **1.0.1** (published 2020-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install react-next-internal-link
pnpm add react-next-internal-link
yarn add react-next-internal-link
bun add react-next-internal-link
```

## 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.0.1 |
| Published | 2020-02-12 |
| First published | 2020-02-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 88.7 KB |
| Known vulnerabilities | 0 (+9 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Lwdthe1 |
| Maintainers | lwdthe1 |
| Keywords | react, link, nextjs, next, internal, internal link, relative link, absolute link, relative url, absolute url, absolute to relative url, components |

## Links

- npm: https://www.npmjs.com/package/react-next-internal-link
- Repository: https://github.com/Lwdthe1/react-next-internal-link
- Homepage: https://github.com/Lwdthe1/react-next-internal-link#readme
- Issues: https://github.com/Lwdthe1/react-next-internal-link/issues
- npm.io page: https://npm.io/package/react-next-internal-link

## Dependencies (3)

- [next](https://npm.io/package/next.md) ^9.2.1
- [url-parse](https://npm.io/package/url-parse.md) ^1.4.7
- [prop-types](https://npm.io/package/prop-types.md) latest

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2020-02-12
- 1.0.0 — 2020-02-12

## README

# react-next-internal-link

A helper component to easily create internal, relative links from absolute urls in your NextJS React apps.

![carbon (38)](https://user-images.githubusercontent.com/5778798/74358582-b0cb5880-4d8f-11ea-9aba-589fbce4fc5e.png)

[![NPM](https://img.shields.io/npm/v/react-next-internal-link.svg)](https://www.npmjs.com/package/react-next-internal-link) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Install

```bash
npm install --save react-next-internal-link
```

## Usage

Import as "InternalLink" and use as illustrated in the examples below. See the tests for examples of more advanced usages.

```jsx
import React, { Component } from "react";

import InternalLink from "react-next-internal-link";

class Example extends Component {
  render() {
    return (
      <div>
        <h1>Example uses:</h1>

        <div>
          <h2>Example 1:</h2>
          <p>Convert absolute url to internal, relative url</p>

          <InternalLink
            href="collection?id=abc123"
            as="http://example.com/collection/abc123"
          >
            <a className="u-textColorGreen">Visit collection abc123</a>
          </InternalLink>

          <div>
            <h3>The result of this example is:</h3>

            <a href="/collection/abc" className="u-textColorGreen">
              Visit collection abc123
            </a>
          </div>
        </div>

        <div>
          <h2>Example 2:</h2>
          <p>
            It still works with urls that have a port, query string, and/or hash
            fragment
          </p>

          <InternalLink
            href="collection?id=abc123"
            as="http://example.com:3100/collection/abc123?user=userA&show=true#div=pricing"
            className="u-textColorGreen"
          >
            <a className="u-textColorGreen">Visit collection abc123</a>
          </InternalLink>

          <div>
            <h3>The result of this example is:</h3>

            <a
              href="/collection/abc?user=userA&show=true#div=pricing"
              className="u-textColorGreen"
            >
              Visit collection abc123
            </a>
          </div>
        </div>
      </div>
    );
  }
}
```

## Test

`npm run test`

## License

By [Lincoln W Daniel](https://lincolnwdaniel.com)

MIT © [Lwdthe1](https://github.com/Lwdthe1)

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