solidjs / solidjs/solid-router

[feat] Conditional routing

Open
#243 2 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
TypeScript
Stars
1.3k
Forks
180
Avg merge
1d 13h
Merged PRs (30d)
19

Description

My feature request is simple, adding conditional routing. The proposal is to add two properties from the Show component into the RouteDefinition interface.

  • when: () => boolean
  • fallback: () => JSX.Element | string | Array<JSX.Element | string>

if when is not defined, use a default value that always computes to true. If the computed value of when() is false render fallback() instead of component or element.

In my opinion this allows a much cleaner syntax for creating routes that should only be available when certain conditions are met. If the conditions are not met it offers a simple way to show the end-user that some condition was not met. If fallback is not defined, treat the route as it is a 404.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the Show component and the RouteDefinition interface mentioned in the proposal, then trace how routes render component or element. Determine how conditional evaluation and fallback rendering fit the existing routing flow. Done means RouteDefinition supports when and fallback, with the specified defaults and 404 behavior when no fallback is provided.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.