|
1 | 1 | # Hanko React-Express Starter
|
2 | 2 |
|
3 |
| -This template shows how you can integrate Hanko with your React App (Vite) and protect routes using express.js middleware. |
| 3 | +This repo demonstrates how to integrate Hanko with React-Express application for authentication and user management. |
4 | 4 |
|
5 |
| -## Clone the repo |
| 5 | +Hanko is an open-source authentication and user management solution with a focus on moving the login beyond passwords while being 100% deployable today. |
| 6 | + |
| 7 | +- Built for [passkeys](https://www.passkeys.io) as introduced by Apple, Google, and Microsoft |
| 8 | +- Fast integration with Hanko Elements web components (login box and user profile) |
| 9 | +- API-first, small footprint, cloud-native |
| 10 | + |
| 11 | +## Prerequisites |
| 12 | + |
| 13 | +Before you begin, ensure you have the following: |
| 14 | + |
| 15 | +- Node.js installed (version 20.0.0 or later) |
| 16 | +- Hanko API URL from [Hanko Cloud](https://cloud.hanko.io/) |
| 17 | + |
| 18 | +> **Note:** |
| 19 | +> You'll need to create a Authentication Project on Hanko Cloud with the App URL `http://localhost:5173`. See our docs to learn how to setup a [auth project](https://docs.hanko.io/setup-hanko-cloud). |
| 20 | +
|
| 21 | +## Getting started |
| 22 | + |
| 23 | +1. Clone the repository |
6 | 24 |
|
7 | 25 | ```bash
|
8 | 26 | git clone https://github.com/teamhanko/hanko-react-express-starter.git
|
9 | 27 | ```
|
10 | 28 |
|
11 |
| -## Get the Hanko API URL |
12 |
| - |
13 |
| -Get the API URL from [Hanko console](https://cloud.hanko.io/) and add it to `.env` file of both frontend and backend directory. |
| 29 | +#### Frontend |
14 | 30 |
|
15 |
| -## Run the project |
16 |
| - |
17 |
| -### Run Frontend |
| 31 | +1. Navigate to the frontend directory: |
18 | 32 |
|
19 | 33 | ```bash
|
20 | 34 | cd hanko-react-frontend
|
21 | 35 | ```
|
22 | 36 |
|
| 37 | +2. Create a `.env` file in the frontend directory (`hanko-react-frontend`) and add the following environment variable: |
| 38 | + |
| 39 | +```sh |
| 40 | +VITE_HANKO_API_URL=your-hanko-api-url |
| 41 | +``` |
| 42 | + |
| 43 | +3. Install the frontend dependencies using your preferred package manager (e.g., `npm`, `pnpm`, `yarn`, or `bun`). For this project, we've used `pnpm`: |
| 44 | + |
23 | 45 | ```bash
|
24 | 46 | pnpm install
|
25 | 47 | ```
|
26 | 48 |
|
| 49 | +4. Start the frontend development server: |
| 50 | + |
27 | 51 | ```bash
|
28 |
| -pnpm run dev |
| 52 | +pnpm dev |
29 | 53 | ```
|
30 | 54 |
|
31 |
| -### Run Backend |
| 55 | +#### Backend |
| 56 | + |
| 57 | +1. Navigate to the backend directory: |
32 | 58 |
|
33 | 59 | ```bash
|
34 | 60 | cd express-server
|
35 | 61 | ```
|
36 | 62 |
|
| 63 | +2. Create a `.env` file in the backend directory (`express-server`) and add the following environment variable: |
| 64 | + |
| 65 | +```sh |
| 66 | +HANKO_API_URL=your-hanko-api-url |
| 67 | +``` |
| 68 | + |
| 69 | +3. Install the backend dependencies: |
| 70 | + |
37 | 71 | ```bash
|
38 | 72 | pnpm install
|
39 | 73 | ```
|
40 | 74 |
|
| 75 | +4. Start the backend server: |
| 76 | + |
41 | 77 | ```bash
|
42 |
| -pnpm run dev |
| 78 | +pnpm dev |
43 | 79 | ```
|
44 | 80 |
|
| 81 | +## Usage |
| 82 | + |
| 83 | +1. Start the application: |
| 84 | + |
| 85 | + - Access the application by navigating to `http://localhost:5173` in your web browser. |
| 86 | + |
| 87 | +2. Navigate to login page and experience Hanko Authentication. |
| 88 | + |
| 89 | + |
| 90 | +## Support |
| 91 | + |
| 92 | +Feel free to reach out to us on [Discord](https://hanko.io/community) if you get into any issues. |
| 93 | + |
| 94 | +## License |
| 95 | + |
| 96 | +This project is licensed under the MIT License. |
| 97 | + |
| 98 | + |
| 99 | + |
0 commit comments