
- Next.js
- React
- Ta'lim
- Boshlanish
Starting a learning platform from zero
20
Today I started working on a learning platform. I created an empty Next.js project and immediately ran into one question: how should the pages for courses, modules and topics be built?
The easiest path was to write a separate page for every course. But that path ends at the second course. By the third one I would be copying the same code for the third time.
So I went the other way: dynamic routes. Course, module and topic all became parameters in the URL. When a page opens, it requests the data it needs and renders it right there.
This is where the first difficulty appeared. In nested dynamic routes every level waits for its own data, but they do not arrive in order. When a topic page opened, I needed to know the module and the course too — otherwise the "back" button had no idea where to return to.
The solution turned out to be simple: every level fetches its own data and does not depend on the level above it. Slower, but the code is far easier to follow. Speed can be added later; tangled code is hard to untangle.
By the end of the day the platform had exactly one course, but creating it required writing zero new pages. Adding a second course is now a matter of minutes.