Bits & Pieces Part 1: They Said Passwordless Was Easy. They Lied. Here's How I Beat It Anyway.
<p><strong><em>Passwords are so 2004. Forget the endless string of forgotten passwords and “Reset your password” emails. In this first installment of our “Bits & Pieces” series, we’re peeling back the curtain on how to build a truly seamless, production‑ready passwordless authentication flow—complete with magic links, SMTP wizardry, and rock‑solid database integration. </em></strong></p><p><br/></p><p>Why am I doing this you might ask?</p><p><br/></p><p>I want an app that feels like magic—one click and you’re in. No typing, no typos, no ‘forgot password?’ panic. Onward!</p><p>But isn’t that just convenience?”</p><p>Convenience is just the tip of the iceberg. Underneath, it’s about seamless onboarding. Imagine a SaaS platform that reduces the friction logins brings.</p><p><em><br/></em></p><p><strong><em>The Hidden Perils of Passwords</em></strong></p><p><br/></p><p>Users today juggle dozens of credentials—two‑thirds of Americans, for instance, admit to reusing the same password across multiple accounts, exponentially raising breach risk.</p><p>Weak, easily guessed passwords like “123456” remain the most common worldwide, used over 4.5 million times in leaked datasets. In 2021 alone, breaches exposed over 22 billion records—many traced back to compromised or reused passwords. </p><p>Requiring users to memorize or reset passwords not only creates friction but also fuels those poor habits—and ultimately undermines security and UX </p><p><br/></p><p><strong><em>Magic Links: and Passwordless authentication: How They Work & Security Trade‑Offs</em></strong></p><p><br/></p><p>When a user submits their email, your backend generates a one‑time token, embeds it in a time‑limited link, and emails it via SMTP. Clicking the link validates the token, establishes a session, and logs them in—no password needed .</p><p>Short lifespans (e.g., 5–15 minutes) dramatically shrink the window for attackers to hijack a stolen link . Malicious sites can overlay invisible iframes or mimic your brand to trick users into clicking links they think are legitimate, always implement X‑Frame‑Options and clear branding in your email templates.</p><p>Some clients strip HTML links; including a plain‑text URL ensures deliverability but also gives attackers a copy‑paste vector—protect tokens with HTTPS and CSRF tokens on the endpoint.</p><p><br/></p><p>Invalidating tokens immediately after first use, prevents replay attacks—store a “used” flag in your database adapter </p><p><strong><em>Let's hack this thing already. </em></strong></p><p><br/></p><p>Well, first of all—a simple how-to on implementing passwordless authentication would suffice, right? Sure. Except that’s not how this really goes down.</p><p><br/></p><p>I wanted to understand this inside-out. Not just slap a package together and hope the auth gods smile on me. No. I wanted to own this flow. Because if a user is going to click one link and get inside my app, that link better be bulletproof. Ironclad. Magical.</p><p>So I started where anyone would—Google. "passwordless authentication <a class="tc-blue" href="https://Next.js" rel="noopener noreferrer" target="_blank">Next.js ↗</a>". The trail leads to <a class="tc-blue" href="https://Auth.js" rel="noopener noreferrer" target="_blank">Auth.js ↗</a>, formerly known as <a class="tc-blue" href="https://NextAuth.js" rel="noopener noreferrer" target="_blank">NextAuth.js ↗</a>. Ah. Rebranded. Just like a startup trying to sound cooler. Whatever. At least the docs exist.</p><p><br/></p><p>First impression? It’s good. Maybe too good. Like that one CS major who turns in perfect assignments but you know they're pasting from somewhere. The magic link section is buried under “Email Provider”—like it doesn’t want to be found. Classic.</p><p>But I read it. Twice. Then once more. Here’s what clicked:</p><p>- You give it an email.</p><p>- It fires off a POST request to `/api/auth/signin/email`.</p><p>- Behind the scenes, a one-time-use token is generated.</p><p>- That token is embedded into a link and emailed via your chosen SMTP provider.</p><p>- User clicks. Token is validated. Boom—they're in.</p><p>But here's where reality smacks you in the face: email providers. Ah yes. You can’t just send email. This isn’t the Wild West. Every provider has opinions.</p><p>Four hours. That’s how long I spent spinning up Mailgun, Resend, SendGrid, and Brevo. One rejected me. Another ghosted. Two others wanted "domain verification." And then I found Postmark.</p><p>Clean. Straightforward. But—requires a verified work email. Not Gmail. Not Yahoo. A real domain. Classic gatekeeping.</p><p>Fine.</p><p>So I hacked the system. Spun up a domain in Google Cloud. Used their $300 free trial to register a real work email. Slapped that on Postmark. Verified. Approved. API key in hand. No payment needed. Production-grade email: unlocked.</p><p><br/></p><p><strong>Now that’s a hack.</strong></p><p><em><br/></em></p><p><strong><em>Next stop: <a class="tc-blue" href="https://Auth.js" rel="noopener noreferrer" target="_blank">Auth.js ↗</a> integration.</em></strong></p><p>Here's the plan:</p><p>1. Add <a class="tc-blue" href="https://Auth.js" rel="noopener noreferrer" target="_blank">Auth.js ↗</a> to our <a class="tc-blue" href="https://Next.js" rel="noopener noreferrer" target="_blank">Next.js ↗</a> app.</p><p>2. Configure the email provider with Postmark using the API key.</p><p>3. Create the `/api/auth/[...nextauth].ts` file.</p><p>4. Use `providers: [EmailProvider({...})]` to hook in the magic link flow.</p><p>5. ENV file gets `POSTMARK_API_TOKEN`, `NEXTAUTH_SECRET`, and the rest.</p><p><br/></p><p>Boom. From 0 to passwordless in under 100 lines of code.</p><p>But this isn’t just about setup. It’s about **user experience**. Clean, crisp emails. Branded links. Instant sessions. No janky redirects. No weird toast notifications. Just… magic.</p><p><br/></p><p>And trust me, we’re just getting started.</p><p><br/></p><p><br/></p><p><br/></p><p><br/></p><p><br/></p><p><br/></p><p><br/></p><p>Next up: **building a custom login UI**, session callbacks, edge cases like expired links, and how to make this thing feel like you’re *signing into the future</p>
Bits & Pieces Part 1: They Said Passwordless Wa...
At the end of each month, we give out cash prizes to 5 people with the best insights in the past month
as well as coupon points to 15 people who didn't make the top 5, but shared high-quality content.
The winners are NOT picked from the leaderboards/rankings, we choose winners based on the quality, originality
and insightfulness of their content.
Here are a few other things to know
1
Quality over Quantity — You stand a higher chance of winning by publishing a few really good insights across the entire month,
rather than a lot of low-quality, spammy posts.
2
Share original, authentic, and engaging content that clearly reflects your voice, thoughts, and opinions.
3
Avoid using AI to generate content—use it instead to correct grammar, improve flow, enhance structure, and boost clarity.
4
Explore audio content—high-quality audio insights can significantly boost your chances of standing out.
5
Use eye-catching cover images—if your content doesn't attract attention, it's less likely to be read or engaged with.
6
Share your content in your social circles to build engagement around it.
Contributor Rankings
The Contributor Rankings shows the Top 20 Contributors on TwoCents a monthly and all-time basis.
The all-time ranking is based on the Contributor Score, which is a measure of all the engagement and exposure a contributor's content receives.
The monthly score sums the score on all your insights in the past 30 days. The monthly and all-time scores are calcuated DIFFERENTLY.
This page also shows the top engagers on TwoCents — these are community members that have engaged the most with other user's content.
Contributor Score
Here is a list of metrics that are used to calcuate your contributor score, arranged from
the metric with the highest weighting, to the one with the lowest weighting.
4
Comments (excluding replies)
5
Upvotes
6
Views
1
Number of insights published
2
Subscriptions received
3
Tips received
Below is a list of badges on TwoCents and their designations.
Comments