Cookbook
Practical, copy-pasteable recipes for common problems. Each recipe is a standalone solution you can drop into your project and adapt.
How to Use
- Find the recipe that matches your problem
- Copy the code into your project
- Adjust names, URLs, and styles to fit your app
TIP
Every recipe uses real AkashJS APIs. If something looks unfamiliar, check the API Reference for the full details.
Recipes
| Recipe | What You'll Build |
|---|---|
| Authentication | Login flow, protected routes, token refresh, role-based access |
| Dark Mode | Theme toggle, system preference sync, CSS variables, transitions |
| Infinite Scroll | Sentinel-based loading, cursor pagination, error retry, scroll restore |
| Modals | Portal-based modals, focus trap, stacked modals, animated enter/exit |
| Data Fetching | createResource, createAction, caching, optimistic updates, retry |
| Advanced Forms | Multi-step wizard, dynamic fields, Zod schema, file inputs |
| Real-Time Updates | WebSocket chat, collaborative state, presence, reconnection |
| File Upload | Drag-and-drop, progress tracking, chunked upload, image preview |
| Drag and Drop | Sortable lists, Kanban board, FLIP animations, drop zones |
| Keyboard Shortcuts | Cmd+K search, scoped shortcuts, help dialog, vim navigation |
Prerequisites
All recipes assume you have an AkashJS project set up:
bash
npx @akashjs/cli new my-app
cd my-app
npm run devINFO
Recipes show the essential code. Production apps should add error handling, loading states, and accessibility attributes beyond what is shown here.