DEV Community

Coding Noob
Coding Noob

Posted on

Breaking free from tutorial hell Part-2

Alright Part 2 of me trying to get out of tutorial hell.

What did I manage to accomplish till now?

Yesterday was an authentication adventure! I plunged into the world of NextAuth and user management, determined to conquer all challenges without the crutch of tutorials(mostly). It wasn't a walk in the park, though.

First, setting up NextAuth with NextJS 14 proved trickier than anticipated. Turns out, only the beta version works with the latest NextJs 14 framework – who knew? After wrestling with beta code and cryptic error messages, I finally managed to make it work somehow, And now I had a basic OAuth with Google and Git Hub, only to face another hurdle: the database adapter.

I envisioned Prisma waltzing with my PostgreSQL database, simplifying interactions with SQL's cryptic tongue. Alas, NextJS middleware and Vercel Edge runtime had a different plan. Prisma Client wasn't welcome there, forcing me to abandon middleware and guard routes with individual page checks.

But hey, progress! Authentication flowed smoothly, user data was comfortably posted to the database. Now came the real dance: building functions for adding, updating, and deleting to-dos.

Here's where things got spicy. Every to-do had to be a one-man show, visible and editable only by its creator. To pull this off, I needed the user ID – a missing piece in the session data. After watching tons of tutorials and reading a lot of docs I managed to figure out how to attach the userid to the session by using a callback function. Finally, the user ID joined the party, allowing me to attach it to to-dos and track each user's creations.

Server-side magic took over once the user ID puzzle was solved. Through carefully orchestrated actions, to-dos were born, each inextricably linked to their creator's ID. This seamless dance of data ensured that every to-do remained visible and editable only to its destined user.

Voila! A small project, built (mostly) solo, free from the clutches of tutorials. It wasn't always graceful and if someone who knows what they are doing read my code they might die of cringe, but the journey was just as rewarding as the destination.

Top comments (0)