Configure KeyHippo Client
Step-by-step guide to setting up the KeyHippo client in your application
After installing the KeyHippo extension in your Supabase database, the next step is to set up the KeyHippo client in your application. This guide will walk you through the process of integrating KeyHippo into your client-side code.
Prerequisites
Before setting up the KeyHippo client, ensure you have:
- Installed the KeyHippo extension in your Supabase database
- A Supabase project with a client application
- Node.js and npm (or yarn) installed in your development environment
Installation
First, install the KeyHippo client package in your project:
Basic Setup
1. Import KeyHippo
In your application code, import the KeyHippo class:
2. Initialize KeyHippo
Create an instance of KeyHippo, passing your Supabase client:
Replace ‘YOUR_SUPABASE_URL’ and ‘YOUR_SUPABASE_ANON_KEY’ with your actual Supabase project details.
Basic Usage
Once you’ve set up the KeyHippo client, you can start using its features:
Creating an API Key
Revoking an API Key
Fetching API Key Information
Advanced Configuration
Custom Logger
KeyHippo allows you to pass a custom logger for more granular control over logging:
Error Handling
KeyHippo uses the Effect library for error handling. Wrap your KeyHippo operations in try-catch blocks to handle potential errors:
Best Practices
- Secure Storage: Never store API keys in client-side code or version control systems.
- Error Handling: Implement error handling for all KeyHippo operations.
- Logging: Use appropriate logging levels and ensure sensitive information is not logged.
- Key Rotation: Implement regular key rotation to enhance security.
- Access Control: Limit API key creation and management to authorized users only.
Troubleshooting
If you encounter issues:
- Connection Problems: Ensure your Supabase client is correctly initialized.
- Permission Errors: Verify that the authenticated user has the necessary permissions in your RLS policies.
- Version Mismatch: Make sure your client package version is compatible with your installed KeyHippo extension.
Next Steps
With the KeyHippo client set up, you can now:
- Implement API key authentication in your application
- Create and manage API keys for your users
- Enhance your Row Level Security policies with KeyHippo functions
Create Policies
Learn how to create RLS policies that leverage KeyHippo for API key authentication.