next-prefixed
Prefix next links and images. Useful when serving from basePath.
Installation
yarn add next-prefixed
Usage
next-prefixed
exports components for rendering prefixed links and images. It also exports a function to prefix any url.
To set the prefix for the URLs, set the assetPrefix
in your next.config.js
.
const debug = processenvNODE_ENV !== 'production';const assetPrefix = debug ? '' : '/your_prefix/'; moduleexports = ;
prefixURL
; ; // => my_prefix/blog
Image
Passes all props to HTML img
tag.
; const Example = <Image src="pony.png" alt="Valiant Horse" />;
Link
Passes all props to next.js Link
component.
; const Example = <Link to="/blog" />;