{"id":13770253,"url":"https://github.com/vgrafe/nextjs-auth0-hasura","last_synced_at":"2025-10-08T05:30:19.582Z","repository":{"id":43965007,"uuid":"209924850","full_name":"vgrafe/nextjs-auth0-hasura","owner":"vgrafe","description":"Template project for Nextjs + Auth0 + Hasura with Apollo.","archived":true,"fork":false,"pushed_at":"2022-02-13T06:37:29.000Z","size":3117,"stargazers_count":61,"open_issues_count":14,"forks_count":9,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-05-19T14:34:24.065Z","etag":null,"topics":["auth0","graphql","hasura","nextjs-starter","nextjs-template"],"latest_commit_sha":null,"homepage":"https://nextjs-auth0-hasura.vercel.app","language":"JavaScript","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vgrafe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-09-21T04:31:22.000Z","updated_at":"2024-05-19T14:34:24.066Z","dependencies_parsed_at":"2022-09-11T02:11:13.623Z","dependency_job_id":null,"html_url":"https://github.com/vgrafe/nextjs-auth0-hasura","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"purl":"pkg:github/vgrafe/nextjs-auth0-hasura","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgrafe%2Fnextjs-auth0-hasura","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgrafe%2Fnextjs-auth0-hasura/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgrafe%2Fnextjs-auth0-hasura/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgrafe%2Fnextjs-auth0-hasura/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vgrafe","download_url":"https://codeload.github.com/vgrafe/nextjs-auth0-hasura/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vgrafe%2Fnextjs-auth0-hasura/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278892036,"owners_count":26063918,"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-10-08T02:00:06.501Z","response_time":56,"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":["auth0","graphql","hasura","nextjs-starter","nextjs-template"],"created_at":"2024-08-03T17:00:35.610Z","updated_at":"2025-10-08T05:30:19.227Z","avatar_url":"https://github.com/vgrafe.png","language":"JavaScript","funding_links":[],"categories":["Templates and Examples"],"sub_categories":[],"readme":"# Deprecated!\n\nHere it is folks, I can not take the time maintaining this project anymore, also since then [the Hasura team is offering a guide](https://hasura.io/learn/graphql/nextjs-fullstack-serverless/introduction/?utm_campaign=learn\u0026utm_medium=social\u0026utm_source=twitter) to have a setup with Nextjs and Auth0 that is definitely better and more secure than this one. Thank you for your interest.\n\n# NextJS - Auth0 - Hasura\n\nThis repo sits on the shoulders of the following giants:\n\n- https://github.com/auth0/nextjs-auth0\n- https://github.com/sandrinodimattia/nextjs-auth0-example\n- https://github.com/zeit/next.js/tree/canary/examples/auth0\n\n## Features\n\n- ⚡️ compatible with Next.js 9's Automatic Static Optimization\n- 🚫 no custom server code\n\n## Demo\n\nTry it [here](https://nextjs-auth0-hasura.vercel.app)\n\nPlease note: the heroku instance might be inactive when you try logging in, resulting in a failed attempt. Try again and it will work. Damn cold starts!\n\nOne way I found to avoid this is to make a dummy http call to the heroku instance in an `_app.js` file:\n\n```js\nimport App from 'next/app';\nimport fetch from 'isomorphic-unfetch';\n\nfetch(process.env.HASURA_GRAPHQL_URL); // wake up that darn instance!\n\nclass MyApp extends App {\n  render() {\n    const { Component, pageProps } = this.props;\n    return \u003cComponent {...pageProps} /\u003e;\n  }\n}\n\nexport default MyApp;\n```\n\n## Shortcomings - Help needed!\n\n- The profile page won't display user data initially. I am shrugging this one off as my goal here is to demonstrate consuming Hasura's gql endpoint and only rely on auth0's idToken to do so.\n- I can't find out how to seamlessly pass the token via cookies as suggested from [Apollo's](https://github.com/apollographql/apollo-client/issues/4455) [documentation](https://github.com/apollographql/apollo-client/issues/4190) and [issues](https://github.com/apollographql/apollo-client/issues/41900). The current workaround is to set cookie manually after auth, but it's ugly and feels unnecessary when if should be provided out of the box by Apollo.\n- the idToken is set/get in a cookie with `js-cookie` in order to add to the headers for calls to hasura (look for all the \"TODO remove when cookie solution found\" comments). It should be handled out of the box by `nextjs-auth0`, so this might be a mistake/overlook of mine.\n- login is janky when using a social button. I don't have much time to troubleshoot this either.\n- a proxi api route should be used to avoid exposing the id token in the client, as explained [here](https://github.com/auth0/nextjs-auth0/issues/67#issuecomment-581599845)\n\n## Setup\n\n- git clone this repository\n- spin up an Hasura instance\n  - generate JWT secret, add it to env vars (HASURA_GRAPHQL_JWT_SECRET)\n  - optionally add the HASURA_GRAPHQL_UNAUTHORIZED_ROLE var\n  - set an HASURA_GRAPHQL_ADMIN_SECRET\n- setup an Auth0 account\n  - copy domain, client ID, secret into `.env` file\n  - add rules found in `auth0` folder (looks like `upsert-user.js` should be above the claim one)\n  - add env vars so the rules work\n    - ADMIN_SECRET (same than HASURA_GRAPHQL_ADMIN_SECRET)\n    - HASURA_GRAPHQL_URL\n  - set callback/redirect URL in your app\n- fill in `hasura/config.yaml` file\n- ```bash\n  cd hasura\n  hasura migrate apply\n  ```\n- ```bash\n  yarn\n  yarn dev\n  ```\n\n## Deploy with zeit's now\n\n- Update `REDIRECT_URI` and `POST_LOGOUT_REDIRECT_URI` in the `now.json` file\n- add all the secrets (start with @ in the file) [with the cli](https://zeit.co/docs/v2/build-step/#using-environment-variables-and-secrets)\n\n## Notes\n\n- [How to](https://dev.to/mikewheaton/public-graphql-queries-with-hasura-2n06) set up public access on hasura.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgrafe%2Fnextjs-auth0-hasura","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvgrafe%2Fnextjs-auth0-hasura","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvgrafe%2Fnextjs-auth0-hasura/lists"}