Skip to content

@unitools/link (alpha)

This is the official documentation of the @unitools/link package.

For Next.js

Installation

Terminal window
npm install @unitools/link @unitools/link-next

or

Terminal window
yarn add @unitools/link @unitools/link-next

Add module resolver to your next.config.js file.

next.config.js
module.exports = {
webpack(config) {
config.resolve.alias["@unitools/link"] = "@unitools/link-next";
return config;
},
};

For Expo

Installation

Install @unitools/link and @unitools/link-expo.

Terminal window
npm install @unitools/link @unitools/link-expo

or

Terminal window
yarn add @unitools/link @unitools/link-expo

Add module resolver to your babel.config.js file.

const path = require("path");
module.exports = function (api) {
api.cache(true);
return {
presets: ["babel-preset-expo"],
plugins: [
[
"module-resolver",
{
alias: {
"@unitools/link": "@unitools/link-expo",
},
},
],
],
};
};

Usage

import Link from "@unitools/link";
export default function Home() {
return (
<View>
<Link href="/about">
<Text>About</Text>
</Link>
</View>
);
}

Props

NameTypeDefaultDescription
hrefstring-The URL the link points to.
childrenReactNode-The content of the link.
asChildbooleanfalseIf true, the link will be rendered as a child component.
pushbooleanfalseIf true, the link will push the new URL to the history stack.
replacebooleanfalseIf true, the link will replace the current URL in the history stack.