This guide details how to acquire the necessary API keys and configuration values for your .env file.
Supabase provides both the database connection and the authentication/storage API keys.
- Create a Project: Go to Supabase and create a new project.
- Get URL and Keys:
- Go to Project Settings (cog icon) -> API.
- Find the
Project URL. This is yourNEXT_PUBLIC_SUPABASE_URL. - Find the
anon/publickey. This is yourNEXT_PUBLIC_SUPABASE_ANON_KEY. - Find the
service_role/secretkey. This is yourSUPABASE_SERVICE_ROLE_KEY.-
WARNING: Never expose the
service_rolekey on the client side.
-
- Get Database URL:
- Go to Project Settings -> Database.
- Under Connection string, make sure "URI" is selected.
- Copy the connection string. It will look like
postgresql://postgres.[ref]:[password]@aws-0-[region].pooler.supabase.com:6543/postgres. - Replace
[password]with the database password you created in step 1. - Set this as your
DATABASE_URL. - Note: For serverless environments (like Vercel/Next.js), use the "Transaction Pooler" connection string (port 6543) if available, or the "Session" mode (port 5432) if you need direct connections.
Helius provides the RPC connection to the Solana blockchain.
- Sign Up: Go to Helius.xyz and sign up.
- Create API Key:
- Go to the Dashboard.
- Generate a new API Key (or use the default one).
- Configure:
- Copy the API Key.
- Set it for both
HELIUS_API_KEYandNEXT_PUBLIC_HELIUS_API_KEY.
Configuration for the authentication handler.
- NEXTAUTH_URL:
- For local development, set this to:
http://localhost:3500(or whatever port you are running on, your.env.examplesuggests 3500). - For production (e.g., Vercel), set it to your canonical domain (e.g.,
https://your-project.vercel.app).
- For local development, set this to:
- NEXTAUTH_SECRET:
- This is a random string used to encrypt session tokens.
- You can generate one using the terminal command:
openssl rand -base64 32
- Or simply type a long random string if you don't have openssl handy (though a secure random string is recommended).
Required for "Sign in with Twitter".
- Developer Portal: Go to the Twitter Developer Portal.
- Create Project/App:
- Create a "Free" account if you haven't (or Basic).
- Create a new Project and an associated App.
- User Authentication Settings:
- Navigate to your App settings -> User authentication settings -> Edit.
- App permissions: Select "Read and write" (or just "Read" if you only need login).
- Type of App: Select "Native App" or "Web App". For NextAuth, Web App, Automated App or Bot is usually appropriate.
- App info:
- Callback URI / Redirect URL: This is crucial. It must match your NextAuth route.
- Local:
http://localhost:3500/api/auth/callback/twitter - Production:
https://your-domain.com/api/auth/callback/twitter
- Local:
- Website URL: Your website homepage (e.g.,
http://localhost:3500).
- Callback URI / Redirect URL: This is crucial. It must match your NextAuth route.
- Save settings.
- Get Keys:
- Go to the Keys and tokens tab.
- Look for OAuth 2.0 Client ID and Client Secret.
- Copy the Client ID to
TWITTER_CLIENT_ID. - Copy the Client Secret to
TWITTER_CLIENT_SECRET. - Note: Do not confuse this with the "Consumer Keys" (API Key and Secret). NextAuth usually uses OAuth 2.0 now, but check if your implementation specifically requires OAuth 1.0. The variable names
CLIENT_IDusually imply OAuth 2.0.
-
DATABASE_URL(Supabase DB Connection String) -
NEXT_PUBLIC_SUPABASE_URL -
NEXT_PUBLIC_SUPABASE_ANON_KEY -
SUPABASE_SERVICE_ROLE_KEY -
HELIUS_API_KEY -
NEXT_PUBLIC_HELIUS_API_KEY -
NEXTAUTH_URL -
NEXTAUTH_SECRET -
TWITTER_CLIENT_ID -
TWITTER_CLIENT_SECRET