New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

clink-react

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clink-react

A Chakra UI v2 Link component that integrates with React Router.

latest
Source
npmnpm
Version
0.2.17
Version published
Maintainers
1
Created
Source

A Chakra UI v2 Link component that integrates with React Router.

Installation

npm install clink-react

Usage

import { BrowserRouter, Routes, Route } from 'react-router-dom'
import Clink from 'clink-react'

<BrowserRouter>
  <ChakraProvider>
    <Clink to='/' color='blue'>Home</Clink>
    <Clink to='/test'>Test</Clink>
    <Clink to='http://npmjs.com' isExternal>NPM</Clink>

    <Routes>
      <Route path='/' element={<>Home page</>} />
      <Route path='/test' element={<>Test page</>} />
    </Routes>
  </ChakraProvider>
</BrowserRouter>

Problem

Chakra UI's Link component provides styling, but React Router's Link component provides routing functionality. Effectively combining them in a reusable component requires boilerplate in the form of combining prop types or awkward wrapping, as well as aliasing one or both imports.

import { HStack, Link as ChakraLink, LinkProps as ChakraLinkProps } from '@chakra-ui/react'
import { Link as ReactRouterLink, LinkProps as ReactRouterLinkProps } from 'react-router-dom'

function NavbarLink (props: ChakraLinkProps & ReactRouterLinkProps): JSX.Element {
  return <ChakraLink as={ReactLink} color='blue' {...props} />
}

function Navbar () {
  return (
    <HStack>
      <NavbarLink to='http://npmjs.com' isExternal>NPM</NavbarLink>
      <NavbarLink to='/about'>About</NavbarLink>
    </HStack>
  )
}

Solution

Clink collapses both components into one. It takes that takes union of their props types as its props. It can receive any props that either Chakra or React Router's Link can. The type of the props it can receive is exported as ClinkProps.

import { HStack } from '@chakra-ui/react'
import Clink, { ClinkProps } from 'clink-react'

function NavbarLink (props: ClinkProps): JSX.Element {
  return <Clink color={blue} {...props} />
}

function Navbar () {
  return (
    <HStack>
      <NavbarLink to='http://npmjs.com' isExternal>NPM</NavbarLink>
      <NavbarLink to='/about'>About</NavbarLink>
    </HStack>
  )
}

Keywords

react

FAQs

Package last updated on 19 Jun 2025

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