Skip to content

ServerlessReact.dev

Student Login
  • Welcome to the workshop
The workshop
Before you head out

Authentication

We're using useAuth for authentication.

  1. Setup a new Auth0 app
  2. Follow instructions in getting started docs
  3. Block twitshot access after 5 pics (use localstorage)

Authentication is not super necessary for this app, but it gives paying users the peace of mind that they're logged in. It also enables session sharing between devices.

And it's a good excuse to try it out :)

User roles

We'll need user roles later. Create a Rule on Auth0 to ensure role info is included with user data.

function (user, context, callback) {
const namespace = 'https://YOUR_DOMAIN';
const assignedRoles = (context.authorization || {}).roles;
user.user_metadata = user.user_metadata || {};
user.user_metadata.roles = assignedRoles;
context.idToken[namespace + '/user_metadata'] = user.user_metadata;
callback(null, user, context);
}

Did you enjoy this chapter?

Previous:
Add core functionality
Next:
Add monetization
Created bySwizecwith ❤️