Template project for Nextjs + Auth0 + Hasura with Apollo.
Here it is folks, I can not take the time maintaining this project anymore, also since then the Hasura team is offering a guide to have a setup with Nextjs and Auth0 that is definitely better and more secure than this one. Thank you for your interest.
This repo sits on the shoulders of the following giants:
Try it here
Please 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!
One way I found to avoid this is to make a dummy http call to the heroku instance in an _app.js
file:
import App from 'next/app';
import fetch from 'isomorphic-unfetch';
fetch(process.env.HASURA_GRAPHQL_URL); // wake up that darn instance!
class MyApp extends App {
render() {
const { Component, pageProps } = this.props;
return <Component {...pageProps} ></Component>;
}
}
export default MyApp;
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..env
fileauth0
folder (looks like upsert-user.js
should be above the claim one)hasura/config.yaml
file
cd hasura
hasura migrate apply
yarn
yarn dev
REDIRECT_URI
and POST_LOGOUT_REDIRECT_URI
in the now.json
file