{"id":24703788,"url":"https://github.com/decelerate/next-guard","last_synced_at":"2025-10-09T09:30:55.639Z","repository":{"id":245493579,"uuid":"818615247","full_name":"Decelerate/next-guard","owner":"Decelerate","description":"next-guard is a lightweight and flexible package for adding security to your Next.js functions. With an easy-to-use guard wrapper, you can protect your routes and actions effortlessly.","archived":false,"fork":false,"pushed_at":"2024-12-04T14:44:03.000Z","size":64,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-03T20:16:43.193Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/Decelerate.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-22T10:44:39.000Z","updated_at":"2024-12-04T14:44:51.000Z","dependencies_parsed_at":"2024-06-22T12:09:37.323Z","dependency_job_id":null,"html_url":"https://github.com/Decelerate/next-guard","commit_stats":null,"previous_names":["decelerate/next-guard"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fnext-guard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fnext-guard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fnext-guard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Decelerate%2Fnext-guard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Decelerate","download_url":"https://codeload.github.com/Decelerate/next-guard/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235807578,"owners_count":19047988,"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":[],"created_at":"2025-01-27T05:59:29.824Z","updated_at":"2025-10-09T09:30:50.337Z","avatar_url":"https://github.com/Decelerate.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Next Guard\n\n`next-guard` is a **lightweight** and **flexible** package for adding security to your Next.js functions. With an easy-to-use guard wrapper, you can protect your routes and actions effortlessly.\n\n## Why would i use this package?\n\nI created this package because i needed a way to protect my Next.js actions. I wanted to be able to add a guard to my functions and protect them with a simple function. This package is perfect for you if you want to add a guard to your functions and protect them with a few lines of code.\n\n---\n\n# Documentation\n\n## Installation\n\nTo install the latest version on npm locally and save it in your package's `package.json` file:\n\n```bash\nnpm install @decelerate/next-guard --save\nyarn add @decelerate/next-guard\n```\n\nTo install the latest development version locally, without updating your project's `package.json` file:\n\n```bash\nnpm install git+https://github.com/Decelerate/next-guard.git\nyarn add git+https://github.com/Decelerate/next-guard.git\n```\n\n---\n\n### Usage\n\n*example.ts*\n```ts\nimport { Guard } from \"@decelerate/next-guard\";\n\nconst AuthGuard = async () =\u003e {\n  // Your authentication logic here\n  const user = await auth();\n\n  if (!user) {\n    return false;\n  }\n\n  return true;\n};\n\nconst myUnprotectedFunction = async () =\u003e {\n  return prisma.user.findMany();\n}\n\nconst myProtectedFunction = Guard(myUnprotectedFunction, AuthGuard)\n```\n\n*example.ts*\n```ts\nimport { Guard } from \"@decelerate/next-guard\";\n\nconst AuthGuard = async () =\u003e {\n  // Your authentication logic here\n  const user = await auth();\n\n  // You can return any type of data in case of error, Guard will automatically type it\n  if (!user) {\n    return {\n      error: \"You are not authenticated\"\n      status: 401\n    };\n  }\n\n  return true;\n};\n\nconst myUnprotectedFunction = async () =\u003e {\n  return prisma.user.findMany();\n}\n\nconst myProtectedFunction = Guard(myUnprotectedFunction, AuthGuard)\n```\n\n---\n\n# Contribute\n\nRequirements :\n- Node.JS \u003e 18.0.0\n\nClone the Git repository and start building good stuff.\n\n```bash\n$ git clone git@github.com:Decelerate/next-guard.git\n$ cd next-auth\n$ yarn\n```\n\nWhen done build everything with `yarn build` and create a pull request respecting git convention.\n\n---\n\n# Credits\n\n- **[Github](https://github.com/Decelerate/next-auth)**\n- **[Arkmind](https://github.com/Arkmind/)**\n  \n---\n\n# License\n\n**[MIT](https://github.com/Decelerate/next-auth/LICENSE)**","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecelerate%2Fnext-guard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdecelerate%2Fnext-guard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdecelerate%2Fnext-guard/lists"}