Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

breadcrumbs-next

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

breadcrumbs-next

The component to display breadcrumbs within NextJS web application

  • 1.0.0
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Breadcrumbs for NextJS

Table of contents

  • Breadcrumbs for NextJS

Behind The Scenes

Click to read!

Imagine your app having the following routes:

  1. /momentum
  2. /projects/[projectId]
  3. /[[…slug]]
  4. /users/[userId]/[[…stuff]]
  5. /users/[userId]/[[…slug]]?t=record
  6. /users?t=record
  7. /users/[userId]?t=record

Last three examples also include URL parameters, which can be used to construct breadcrumbs. For example, when you have a page consisting from another set of tabs, but you don't want to create another route for that.

All of those examples can be transformed to the following formats (lets omit Home element in resulting breadcrumbs):

PatternBreadcrumbsExample URL
/momentumMomentum=
/profile?t=recordsProfile > Records=
/projects/[projectId]Projects > "Grammar"/projects/17
/[[…slug]]Russia > Moscow > Subway > Kommunarka/russia/moscow/subway/kommunarka
/users/[userId]/[[…stuff]]Users > Pavel > Deliveries > Yandex > Lavka/users/132/deliveries/yandex/lavka
/users/[userId]/[[…slug]]?t=records[1]Users > Pavel > Deliveries > Dashboard > Record/users/132/deliveries/dashboard?t=records
/users/[userId]?t=recordsUsers > Pavel > Records/users/132?t=records

[1] - Search params always are taken last, because change of URL (w/o params) is the same as opening another page, thus even having the same params set int the URL doesn't mean they should go in the beginning. They are behaviour modifiers of the page, but not its primary descriptor.

Contents

Type Aliases

  • BreadCrumb
  • CrumbProps
  • GetDefaultTextGenerator
  • GetTextGenerator
  • NextBreadcrumbsProps
  • TextGeneratorFn

Components

  • NextBreadcrumbs

Functions

  • createNextCrumbComponent

Type Aliases

BreadCrumb

Ƭ BreadCrumb: Object

Type declaration
NameType
hrefstring
textstring
textGeneratornull or TextGeneratorFn

CrumbProps

Ƭ CrumbProps: Object

Index signature

▪ [key: string]: any

Type declaration
NameType
hrefstring
isLastboolean
textstring

GetDefaultTextGenerator

Ƭ GetDefaultTextGenerator: (config: { href: string ; paramIndex: number ; paramName: string ; paramSlugIndex: number ; paramValue: string ; query: NextRouter["query"] }) => string

Type declaration

▸ (config): string

Parameters
NameType
configObject
config.hrefstring
config.paramIndexnumber
config.paramNamestring
config.isCatchAllSubpathboolean
config.paramSlugIndexnull or number
config.paramValuestring
config.queryNextRouter["query"]
Returns

string


GetTextGenerator

Ƭ GetTextGenerator: (config: { href: string ; paramIndex: number ; paramName: string ; paramSlugIndex: number ; paramValue: string ; query: NextRouter["query"] }) => null | TextGeneratorFn

Type declaration

▸ (config): null | TextGeneratorFn

Parameters
NameType
configObject
config.hrefstring
config.paramIndexnumber
config.paramNamestring
config.isCatchAllSubpathboolean
config.paramSlugIndexnull or number
config.paramValuestring
config.queryNextRouter["query"]
Returns

null | TextGeneratorFn


NextBreadcrumbsProps

Ƭ NextBreadcrumbsProps: Object

Type declaration
NameType
Containerstring or FC<{children: ReactNode}\>
CrumbFC<CrumbProps>
getDefaultTextGenerator?GetDefaultTextGenerator
getTextGenerator?GetTextGenerator
homeText?string
useQueryParamsAsPathItems?string[]

TextGeneratorFn

Ƭ TextGeneratorFn: () => Promise<string>

Type declaration

▸ (): Promise<string>

Returns

Promise<string>

Components

NextBreadcrumbs

NextBreadcrumbs(«destructured»): JSX.Element

Parameters
NameType
«destructured»NextBreadcrumbsProps
Returns

JSX.Element


Functions

createNextCrumbComponent

createNextCrumbComponent(Component): FC<{ text: string ; textGenerator: null | TextGeneratorFn }\>

Parameters
NameType
ComponentFC<{ children: ReactNode }\>
Returns

FC<{ text: string; textGenerator: null | TextGeneratorFn }\>

Backlog

Here I would place any ideas to make in the future.

  • add support for query params to be items of breadcrumbs

Keywords

FAQs

Package last updated on 27 Mar 2023

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