Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

229
Views
How would I use date in Next.js api to generate boolean if todo item should be visible?

I might have gotten things all messed up, but I'm trying to build something using only Next.js where if a certain date has passed, my todo items should become visible.

I know I can't simply use new Date() in the client, because that would make it possible for anyone to manipulate the time of the client to render the content visible.

So my question is, it is possible doing something like this with Next.js's built in api?

/api/todos.js

export default function handler(req, res) {
  const now = new Date();

  res.status(200).json([
    {
      title: 'Todo 1',
      id: 1,
      isOpened: false,
      canBeOpened: now >= new Date('2021-12-01'),
    },
    {
      title: 'Todo 2',
      id: 1,
      isOpened: false,
      canBeOpened: now >= new Date('2021-12-02'),
    },
  ]);
}

I'm planning on hosting this on netlify, but I'm not sure what time they might be using. Is this approach possible?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!