r/react • u/yawboakye • 1d ago
Project / Code Review cogni: give your next react screen a head start
say you have an orders page that loads its javascript when someone clicks “orders”. there’s often a little time between the pointer settling on the link and the click. cogni can start the import in that gap. by the time the user clicks, some or all of the work may already be done.
we built this at inttegro because starting the request is the easy part. suppose the user hovers over “orders” and then opens “products”. the orders request might have finished just fine. it still didn’t help. cogni puts a budget on speculative work and learns from what the app actually reuses. you can see both outcomes in devtools.
if you use react router or tanstack router, start with one PredictiveLink on a screen that’s slow to open. cogni uses the router’s existing cache, so you can try it on one route before deciding whether it belongs anywhere else. if you’ve built your own navigation, the plain react demo shows the whole thing with two lazy imports and useRouteIntent.
it’s MIT-licensed. here’s the repo and the react demo. i’ll be around if anyone has questions.
4
u/Honey-Entire 1d ago
This already exists and doesn’t require React…
2
u/Intelligent-Main539 1d ago
Posts like this feel like just a way to get a product promoted.
+1 for the other comment.