A simple Single Page Application (SPA) built with Vue.js and TypeScript, demonstrating social login integration with Auth0.
- User authentication with Auth0
- Social login support for multiple providers (Google, Facebook, Twitter, Microsoft, Apple)
- Protected routes for authenticated users only
- TypeScript for type safety
- Environment variable configuration for sensitive data
- Node.js (version 16 or higher)
- npm (version 8 or higher)
-
Clone the Repository
git clone <repository-url>
-
Install Dependencies
npm install
-
Configure Environment Variables
Copy the
.env.local.examplefile to.env.localand update the values with your Auth0 credentials:cp .env.local.example .env.local
Edit
.env.localto include your Auth0 domain and client ID:VITE_AUTH0_DOMAIN=your-auth0-domain-here VITE_AUTH0_CLIENT_ID=your-auth0-client-id-hereEnsure
.env.localis not committed to version control (it's already in.gitignore). -
Run the Development Server
npm run dev
The application will be available at
http://localhost:3000(or the next available port if 3000 is in use).
- Open your browser and navigate to
http://localhost:3000. - Click on "Log In" to authenticate using Auth0.
- You'll be redirected to the Auth0 login page where you can choose a social login provider.
- After successful login, you can access the protected
/profileroute to view user information. - Click "Log Out" to end your session and return to the homepage.
src/main.ts: Entry point of the application, initializes Vue and Auth0.src/App.vue: Main component with navigation links.src/views/Home.vue: Home page component.src/views/Profile.vue: Protected profile page displaying user information.src/components/LoginSelector.vue: Custom component for selecting social login providers.src/router/index.ts: Router configuration with route guards for authentication.
Sensitive configuration values are stored in environment variables:
VITE_AUTH0_DOMAIN: Your Auth0 domain.VITE_AUTH0_CLIENT_ID: Your Auth0 client ID.
These are loaded from a .env.local file, which should not be committed to version control.
To build the application for production:
npm run buildThe output will be in the dist directory.
This project is licensed under the MIT License - see the LICENSE file for details (if applicable).
Contributions are welcome! Please feel free to submit a Pull Request.