{"id":30186317,"url":"https://github.com/brian-dlee/remix-return-navigation","last_synced_at":"2025-08-12T14:11:17.281Z","repository":{"id":50546402,"uuid":"519366526","full_name":"brian-dlee/remix-return-navigation","owner":"brian-dlee","description":"Create smooth return navigation using Remix","archived":false,"fork":false,"pushed_at":"2023-07-19T20:04:54.000Z","size":2339,"stargazers_count":2,"open_issues_count":3,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-07-24T16:54:12.648Z","etag":null,"topics":["html","navigation","no-javascript","react","referer","remix","ssr"],"latest_commit_sha":null,"homepage":"https://remix-return-navigation.brian-dlee.dev","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/brian-dlee.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-29T22:44:21.000Z","updated_at":"2023-02-07T13:20:40.000Z","dependencies_parsed_at":"2023-02-18T17:31:37.012Z","dependency_job_id":null,"html_url":"https://github.com/brian-dlee/remix-return-navigation","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/brian-dlee/remix-return-navigation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brian-dlee%2Fremix-return-navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brian-dlee%2Fremix-return-navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brian-dlee%2Fremix-return-navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brian-dlee%2Fremix-return-navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brian-dlee","download_url":"https://codeload.github.com/brian-dlee/remix-return-navigation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brian-dlee%2Fremix-return-navigation/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270073680,"owners_count":24522393,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-12T02:00:09.011Z","response_time":80,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["html","navigation","no-javascript","react","referer","remix","ssr"],"created_at":"2025-08-12T14:11:16.731Z","updated_at":"2025-08-12T14:11:17.275Z","avatar_url":"https://github.com/brian-dlee.png","language":"TypeScript","readme":"# remix-return-navigation\n\nCreate smooth return navigation with Remix. This library retains all existing state within a URL, promotes the\nuse of native web practices for navigation, and makes return navigation easy to implement for both clients with and\nwithout Javascript enabled.\n\n## Getting started\n\n```shell\nnpm i --save @briandlee/remix-return-navigation\n```\n\n## View the Demo\n\nThe live demo is available at https://remix-return-navigation.brian-dlee.dev/.\n\nThe code for the demo is in the [demo directory](demo).\n\n### Install the `ReturnNavigationContext`\n\nInstalling the context allows the application to encapsulate the server provided\nreferrer as we as listening for client-side navigations. The context must be installed so\nthat the `returnLocation` will be computed and available to `ForwardLink` components.\n\n```typescript jsx\nimport type { LoaderFunction } from '@remix-run/node';\nimport { json } from '@remix-run/node';\nimport {\n  getReturnNavigationState,\n  ReturnNavigationContextProvider,\n} from '@briandlee/remix-return-navigation';\n\nexport const loader: LoaderFunction = async ({ request }) =\u003e {\n  const state = getReturnNavigationState(request);\n\n  return json({ referrer: state.referrer, requestUrl: state.requestUrl });\n};\n\nexport default function App() {\n  const { referrer, requestUrl } = useLoaderData();\n  return (\n    \u003chtml lang=\"en\"\u003e\n      \u003chead\u003e\n        \u003cMeta /\u003e\n        \u003cLinks /\u003e\n      \u003c/head\u003e\n      \u003cbody\u003e\n        \u003cReturnNavigationContextProvider referrer={referrer} requestUrl={requestUrl}\u003e\n          \u003cOutlet /\u003e\n        \u003c/ReturnNavigationContextProvider\u003e\n        \u003cScrollRestoration /\u003e\n        \u003cScripts /\u003e\n        \u003cLiveReload /\u003e\n      \u003c/body\u003e\n    \u003c/html\u003e\n  );\n}\n```\n\n### Using `ForwardLink`\n\nAdd a `ForwardLink` to automatically add a return location to a link.\n\n\u003e _Note: `ForwardLink` wraps `Link` from `@remix-run/react`. It only adds the current location as a search param to enable return navigation._\n\n```typescript jsx\nimport { ForwardLink } from '@briandlee/remix-return-navigation';\n\nexport default function SourcePage() {\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eHello, {user.displayName}\u003c/h1\u003e\n      \u003cForwardLink to={'target'}\u003eGo\u003c/ForwardLink\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n### Using `BackwardLink`\n\nAdd a `BackwardLink` to add a link to return the user to the previous location.\n\n\u003e _Note: `BackwardLink` also wraps `Link` from `@remix-run/react`, but it does not accept `to` since it generates it from the current return location._\n\n```typescript jsx\nimport type { LoaderFunction } from '@remix-run/node';\nimport { json } from '@remix-run/node';\nimport { BackwardLink } from '@briandlee/remix-return-navigation';\n\nexport default function TargetPage() {\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eHello, {user.displayName}\u003c/h1\u003e\n      \u003cBackwardLink fallback=\"/profile\" fallbackContent={\"Go to Profile\"}\u003e\n        Return\n      \u003c/BackwardLink\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n#### Fully customize the `BackwardLink` content using a FunctionalComponent\n\n```typescript jsx\nimport type {LoaderFunction} from '@remix-run/node';\nimport {json} from '@remix-run/node';\nimport {BackwardLink, BackwardLinkFC} from '@briandlee/remix-return-navigation';\n\nexport default function TargetPage() {\n  return (\n    \u003cdiv\u003e\n      \u003ch1\u003eHello, {user.displayName}\u003c/h1\u003e\n      \u003cBackwardLink render={LinkContent} /\u003e\n    \u003c/div\u003e\n  );\n}\n\nconst LinkContent: BackwardLinkFC = ({ returnLocation }) =\u003e {\n  if (returnLocation) {\n    return (\n      \u003c\u003e\u003cIcon name={'back'} /\u003e Go back to {returnLocation.pathname}\u003c/\u003e\n    )\n    \n    return \u003c\u003e\u003cIcon name={'home'} /\u003e Go home\u003c/\u003e\n  }\n}\n```\n\n## Related issues\n\nWorks around a known issue: https://github.com/remix-run/remix/issues/3510\n\n---\n\nCreated by [me](https://brian-dlee.dev/).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrian-dlee%2Fremix-return-navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrian-dlee%2Fremix-return-navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrian-dlee%2Fremix-return-navigation/lists"}