{"id":23020583,"url":"https://github.com/dipeshrai123/next-auth-navigation","last_synced_at":"2025-08-14T09:32:21.940Z","repository":{"id":55495189,"uuid":"324091804","full_name":"dipeshrai123/next-auth-navigation","owner":"dipeshrai123","description":"NextJS Library for authentication","archived":false,"fork":false,"pushed_at":"2020-12-27T05:23:54.000Z","size":293,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2023-03-04T02:32:39.251Z","etag":null,"topics":["authentication","next-auth-navigation","nextjs"],"latest_commit_sha":null,"homepage":"","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/dipeshrai123.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-12-24T07:11:42.000Z","updated_at":"2021-11-15T08:56:57.000Z","dependencies_parsed_at":"2022-08-15T01:40:55.195Z","dependency_job_id":null,"html_url":"https://github.com/dipeshrai123/next-auth-navigation","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Fnext-auth-navigation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Fnext-auth-navigation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Fnext-auth-navigation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dipeshrai123%2Fnext-auth-navigation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dipeshrai123","download_url":"https://codeload.github.com/dipeshrai123/next-auth-navigation/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229815959,"owners_count":18128512,"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","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":["authentication","next-auth-navigation","nextjs"],"created_at":"2024-12-15T12:14:28.503Z","updated_at":"2024-12-15T12:14:28.961Z","avatar_url":"https://github.com/dipeshrai123.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next Auth Navigation\n\n\u003e NextJS Library for authentication\n\n[![NPM](https://shields.io/npm/v/next-auth-navigation.svg)](https://www.npmjs.com/package/react-auth-navigation) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n\n## Install\n\n```bash\n// with npm\nnpm i next-auth-navigation\n\n// with yarn\nyarn add next-auth-navigation\n```\n\n## Why is next-auth-navigation ?\n\nIt is a NextJS Library for user authentication in client / server side. It provides basic HOC's that to wrap around pages to authenticate user very easily.\n\n## Usage\n\n### Authentication\n\n**next-auth-navigation** only provides 2 helpful hocs to define user authentication in client / server side. Both hocs must be used for authentication.\n\n- **withAuth()** and\n- **withAuthServerSideProps()**\n\n#### withAuth(_Component_, _options?_)\n\n**withAuth()** accepts a _component_ for which we wan an authentication as a first argument and _options_ as a second argument. _options_\n\nLet us configure the _second argument_.\n\n- **redirectUri** _( optional )_ : If the user is not logged in, user is redirected to path assigned in _redirectUri_.\n- **authenticatedUri** _( optional )_ : If the user is logged in, user is redirected to path assigned in _authenticatedUri_.\n- **FallbackComponent** _( optional )_ : If the user is not logged in, Fallback component is shown on a page.\n- **FeedbackComponent** _( optional )_ : Feedback component is shown when redirecting either on _redirectUri_ or _authenticatedUri_.\n\n#### withAuthServerSideProps(_options?_, _callback?_)\n\n**withAuthServerSideProps()** is used instead of **getServerSideProps()** function on a page with **withAuth()** hoc. It is used to authenticate user in server-side. **options** is passed as a first optional argument where we can specify _redirectUri_ or _authenticatedUri_ for server-side redirection. **callback** function can be provided as second argument which acts as a **getServerSideProps()** function with _context_ as a first argument and _data_ as a second argument reffering all _cookie data_.\n\n**Example**\n\n```javascript\nimport { withAuth, withAuthServerSideProps } from \"next-auth-navigation\";\nfunction Home() {\n  return \u003cdiv\u003eHOME PAGE\u003c/div\u003e;\n}\n\nexport default withAuth(Home, {\n  redirectUri: \"/login\",\n});\n\nexport const getServerSideProps = withAuthServerSideProps();\n```\n\n## License\n\nMIT © [dipeshrai123](https://github.com/dipeshrai123)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipeshrai123%2Fnext-auth-navigation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdipeshrai123%2Fnext-auth-navigation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdipeshrai123%2Fnext-auth-navigation/lists"}