import { trpc } from '@/lib/trpc';function CreateKeyButton() { const createKey = trpc.keys.create.useMutation({ onSuccess: (data) => { // Show the secret to the user alert(`Your API key: ${data.secret}\n\nSave this now!`); }, }); const handleCreate = () => { const name = prompt('Enter a name for this key:'); if (name) { createKey.mutate({ name }); } }; return ( <button onClick={handleCreate}> Create New API Key </button> );}
// After creating a keyconst newKey = await createKey.mutate({ name: 'Production Key' });// ✅ Store in environment variablesconsole.log('Add this to your .env file:');console.log(`SATORI_API_KEY=${newKey.secret}`);// ❌ Don't commit to version control// ❌ Don't store in client-side code// ❌ Don't share via insecure channels