Storx uses ImageKit as its file storage and CDN layer. When a user uploads a file, Storx sends the binary data to ImageKit and stores the returned delivery URL in Neon PostgreSQL. All subsequent file access goes directly through the ImageKit CDN — no file bytes are stored in the database or on the Next.js server.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/nayalsaurav/Storx/llms.txt
Use this file to discover all available pages before exploring further.
Creating an ImageKit Account
Sign up at imagekit.io
Go to imagekit.io and create a free account. The
free tier includes 20 GB of storage and 20 GB of bandwidth per month, which
is sufficient for development and small-scale use.
Locate your credentials
After signing in, open the Developer Options section in the ImageKit
dashboard (or go to Settings → API Keys). You will find:
- Public Key — safe to use in the browser
- Private Key — server-only; never expose this to the client
- URL Endpoint — the base URL for all files in your account, e.g.
https://ik.imagekit.io/your_imagekit_id
How Storx Uses ImageKit
ImageKit Instance
A single ImageKit client is initialised once inlib/imagekit.ts and imported wherever uploads or authentication parameters are needed:
lib/imagekit.ts
Upload Path Structure
Every file is placed in a deterministic folder path inside ImageKit based on the uploading user’s Clerk ID and the optional parent folder ID:| Scenario | ImageKit folder path |
|---|---|
| File at the root level | /storex/{userId}/ |
| File inside a nested folder | /storex/{userId}/folder/{parentId}/ |
550e8400-e29b-41d4-a716-446655440000.pdf). This is generated server-side so filenames are always unique within a folder:
app/api/files/upload/route.ts
useUniqueFileName: false is explicitly set because Storx manages uniqueness itself via UUIDs. Letting ImageKit append its own suffix would make the stored filename unpredictable.
Authentication Parameters
Client-side ImageKit uploads require a short-lived token that proves the request is authorised. Storx exposes aGET /api/imagekit-auth endpoint that:
- Validates the caller has an active Clerk session
- Calls
imagekit.getAuthenticationParameters()on the server (using the private key) - Returns the token, expire time, and signature to the browser
app/api/imagekit-auth/route.ts
401 for unauthenticated callers and 500 if parameter generation fails.
Supported File Types
Only two MIME type groups are accepted. Any other type is rejected at the upload API route before the file is sent to ImageKit:| Accepted | MIME pattern |
|---|---|
| Images | image/* (JPEG, PNG, WebP, GIF, SVG, …) |
| Documents | application/pdf |
app/api/files/upload/route.ts
.docx, .zip, .mp4) returns a 400 Bad Request response with the message "Only images and PDF files are supported".
ImageKit’s free tier provides 20 GB of storage and 20 GB of monthly bandwidth.
For a production deployment with multiple users, monitor your usage in the
ImageKit dashboard and upgrade to a paid plan before hitting the limits.
Exceeding the free quota does not automatically delete files, but new uploads
and CDN delivery may be restricted until the plan is upgraded.