The following is a guide to launch a Next.JS project that uses Auth0 for authentication and TakeShape to store custom user profile information.
This is a Next.js project bootstrapped with
create-next-app.
-
Create an Auth0 account, if you haven't already at auth0.com.
-
Create an Auth0 application by going to the
Applicationspage under theApplicationstab on the left.- Choose to create a
Regular Web Application. - Take note of your
domain, you'll need it later. It typically looks like this:dev-by9w1mxg.us.auth0.com. - Go to the
Settingstab, scroll down, and fill in the following fields:- Allowed Callback URLs: http://localhost:3000/api/auth/callback
- Allowed Logout URLs: http://localhost:3000/
- Allowed Web Origins: http://localhost:3000/
- Allowed Origins (CORS): http://localhost:3000/
- Scroll down to the very bottom of page and click Save Changes; the application doesn't automatically save itself!
- Choose to create a
-
Create a TakeShape project using the pattern in this repo. This button will deploy the project for you:
-
Create an Auth0 service in your new TakeShape project.
- Go to the
Schematab, then clickConnect Service. - Type in your Auth0
domainfrom the earlier step. - Take note of the
audiencefrom the TakeShape config screen, you'll need it later. - Save the service.
- Go to the
-
Set up your TakeShape API Key.
- Go to the API tab, then to API Keys.
- Create a new API Key.
- Give it
Readpermissions. - Copy the key and save it somewhere. This is the only time you'll see it.
-
Now go back to your Auth0 account and create an API (it's on the
APIspage under theApplicationstab on the left).- Set the
identifierto theaudienceyou encountered earlier on the TakeShape Auth0 Service page. - Leave the signing algorithm as
RS256. - Create the API.
- Set the
-
Head over to your trusty terminal or tool of choice.
- Clone this repo with
git clone https://github.com/takeshape/takeshape-starter-auth0.git. cdinto the folder that the cloning created.- Run
mv .env.local-example .env.localto rename the environment variables file. - Run
npm install.
- Clone this repo with
-
Follow the instructions in
.env.local. Some of the data you enter will be from Auth0; some of it will be from TakeShape. -
Run
npm run devto start the application and open http://localhost:3000 with your browser to play around!
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!