New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-next-internal-link

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-next-internal-link

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

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

carbon (38)

NPM JavaScript Style Guide

Install

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.

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

MIT © Lwdthe1

Keywords

FAQs

Package last updated on 12 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc