Prerequisites
- Next.js 13+ with the App Router (
app/directory) - TypeScript (recommended — types shown throughout this guide)
Setup
1
Create the API route file
Create a new file at The route reads
app/api/analyze/route.ts. Next.js will automatically expose this as POST /api/analyze when the app is running.PARALENS_API_URL from the server environment and forwards the request body as-is. The upstream HTTP status is preserved so your frontend error handling works correctly.2
Add the environment variable
Add the Railway base URL to
.env.local. This file is read only by Next.js server-side code and is never included in the client bundle.3
Call the proxy from your frontend
In any client component, call
/api/analyze instead of the Railway URL directly.4
(Optional) Add response caching
Ethereum transactions are immutable once confirmed, so the same hash will always produce the same report. Add caching at the proxy layer to avoid redundant upstream calls.See the Adding Caching section below for an in-memory and Redis example.
Adding Caching
Because confirmed transactions never change, you can safely cache responses indefinitely. A 24-hour TTL is a practical default that balances freshness with performance. In-memory cache — suitable for single-instance deployments or development:ioredis or the @upstash/redis client:
Future API Key Support
ParaLens does not require authentication today, but future-compatible clients should be prepared to send anx-api-key header. When API keys are introduced, update your proxy to read PARALENS_API_KEY from the server environment and forward it — no changes needed in your frontend components.
.env.local when you receive one:
Never expose your Railway URL or API key in client-side code or public environment variables (i.e., variables prefixed with
NEXT_PUBLIC_). Always read credentials in server-only code such as API routes, Server Components, or getServerSideProps.Next Steps
Now that your proxy is set up, head to Dashboard Layouts to learn how to useclassification.intent_kind to choose the right UI layout for each transaction type.