Prerequisites
- TimeBack API server running (usually on
http://localhost:8080) - Bun or Node.js installed
- Access to the TimeBack SSO SDK
Step 1: Create New Vite Project
Step 2: Install TimeBack SSO SDK
Choose one of the following methods:Method A: Local File Reference (Development)
If the SDK is on your local machine:Method B: GitHub Repository
If the SDK is published on GitHub:Method C: Built Package Copy
-
Build the SDK:
-
Copy the
distfolder to your project assrc/lib/timeback-sso/ -
Import directly:
Step 3: Basic Integration
Replace yoursrc/App.tsx with:
Step 4: Add Basic Styling
Update yoursrc/App.css:
Step 5: Configure Vite (Optional)
If you need to customize the Vite config, updatevite.config.ts:
Step 6: Run Your Application
Testing SSO
To test the SSO functionality:- Login in your application
- Open the demo app at
http://localhost:8082(if running) - Or open your app in an incognito window on a different port
- The SSO should automatically authenticate you
Advanced Features
Making Authenticated API Calls
Using the React Hook (if available)
If the React hook is working in your environment:Troubleshooting
Common Issues
- Module not found: Make sure the SDK is properly installed and built
- CORS errors: Ensure your API server allows requests from your domain
- SSO not working: Check that both apps are whitelisted in the backend
- TypeScript errors: Ensure you have the latest TypeScript definitions
Development vs Production
For development, use the local file reference method. For production, you’ll want to:- Publish the SDK to a private npm registry, or
- Include it as a git submodule, or
- Bundle it directly into your application
Next Steps
- Explore the full demo application for more advanced examples
- Review the TimeBack SSO overview for deeper understanding
- Check the TimeBack API documentation for available endpoints