Learn how to quickly add authentication and user profile in your Angular app using Hanko.
@teamhanko/hanko-elements
hanko-auth
and hanko-profile
.
APP URL
.
(Most likely http://localhost:4200/)environments.ts
within your /src
folder.
Retrieve your API URL from the Hanko console and place it in your .env file.
HankoAuth
and HankoProfile
components.
Run these commands in the terminal.
HankoAuth
component.
For more information please refer to the Auth Component Page.
HankoProfile
component to create a interface where users can manage their Email Addresses
and credentials.
For more information please refer to the Profile Component Page.
app.component.html
file and add a router outlet.
app.routes.ts
file and setup your routes.
/
to see the <HankoAuth>
, and to /dashboard
to see the <HankoProfile>
.
They should look something like this👇
ng serve
to start the server.@teamhanko/hanko-elements
to easily log users out. Here we will make a logout button component that you can use anywhere.
Create the LogoutButton component with this command.
hanko-auth
and hanko-profile
components using CSS variables and parts. Refer to our customization guide.
guard
that will check for authentication before the router activates the pages.
Create the authentication guard with this command.
auth.guard.ts
, insert this code.
This will grab the hanko session token and send it to the backend for validation.
app.routes.ts
, which should only be accessible when the user is logged in.