|
1 | | -# Vue/JavaScript: Starter SPA Code Sample |
| 1 | +# Vue/JavaScript: Basic User Authentication Code Sample |
2 | 2 |
|
3 | | -This JavaScript code sample demonstrates how to build a Single-Page Application (SPA) using Vue. This Vue code sample builds the API server using the Vue Composition API. |
| 3 | +This JavaScript code sample demonstrates **how to implement user authentication** in Vue applications using Auth0. This Vue code sample builds the Single-Page Application (SPA) using the Vue Composition API. |
4 | 4 |
|
5 | | -Visit the ["Vue/JavaScript Code Samples: SPA Security in Action"](https://developer.auth0.com/resources/code-samples/spa/vue) section of the ["Auth0 Developer Resources"](https://developer.auth0.com/resources) to explore how you can secure Vue applications written in JavaScript by implementing endpoint protection and authorization with Auth0. |
| 5 | +This code sample is part of the ["Auth0 Developer Resources"](https://developer.auth0.com/resources), a place where you can explore the authentication and authorization features of the Auth0 Identity Platform. |
6 | 6 |
|
7 | | -[](https://developer.auth0.com/resources/code-samples/spa/vue) |
| 7 | +Visit the ["Vue/JavaScript + Composition API Code Sample: User Authentication For Basic Apps"](https://developer.auth0.com/resources/code-samples/spa/vue/basic-authentication) page for instructions on how to configure and run this code sample and how to integrate it with an API server of your choice to [create a full-stack code sample](https://developer.auth0.com/resources/code-samples/full-stack/hello-world/basic-access-control/spa). |
| 8 | + |
| 9 | +[](https://developer.auth0.com/resources/code-samples/spa/vue/basic-authentication) |
8 | 10 |
|
9 | 11 | ## Why Use Auth0? |
10 | 12 |
|
11 | 13 | Auth0 is a flexible drop-in solution to add authentication and authorization services to your applications. Your team and organization can avoid the cost, time, and risk that come with building your own solution to authenticate and authorize users. We offer tons of guidance and SDKs for you to get started and [integrate Auth0 into your stack easily](https://developer.auth0.com/resources/code-samples/full-stack). |
12 | | - |
13 | | -## Set Up and Run the Vue Project |
14 | | - |
15 | | -Install the project dependencies: |
16 | | - |
17 | | -```bash |
18 | | -npm install |
19 | | -``` |
20 | | - |
21 | | -The starter Vue project offers a functional application that consumes data from an external API to hydrate the user interface. For simplicity and convenience, the starter project simulates the external API locally using [`json-server`](https://github.com/typicode/json-server). |
22 | | - |
23 | | -However, you can also integrate this starter project with any of the ["Hello World" API code samples, which are available in multiple backend frameworks and programming languages](https://github.com/orgs/auth0-developer-hub/repositories?language=&q=api+hello-world&sort=&type=public). |
24 | | - |
25 | | -The compatible API server runs on `http://localhost:6060` by default. As such, to connect your Vue application with that API server, create a `.env` file under the root project directory and populate it with the following environment variables: |
26 | | - |
27 | | -```bash |
28 | | -VITE_API_SERVER_URL=http://localhost:6060 |
29 | | -``` |
30 | | - |
31 | | -Next, execute the following command to run the JSON server API: |
32 | | - |
33 | | -```bash |
34 | | -npm run api |
35 | | -``` |
36 | | - |
37 | | -Finally, open another terminal tab and execute this command to run your Vue application: |
38 | | - |
39 | | -```bash |
40 | | -npm run dev |
41 | | -``` |
42 | | - |
43 | | -Visit [`http://localhost:4040/`](http://localhost:4040/) to access the starter application. |
44 | | - |
45 | | -In the starter project, all the starter Vue application routes are public. However, you can use Auth0 to get an ID token to hydrate the user profile information present on the `/profile` page with information from a real user. With Auth0, you can also get an access token to make a secure call to an external API to hydrate the messages present in the `/protected` and `/admin` pages. |
0 commit comments