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

233
Views
Next.js imports from root directory: is it valid to start an import with a slash?

This import works, but I can't find any documentation saying that it's valid:

// rather than do a crazy nested import like this
import { myUtil } from '../../../../../lib/utils'

// this appears to work just fine
import { myUtil } from '/lib/utils'

I see where the official answer is to set up a config file with a @ alias, so I suppose I will just do that to be compliant. Just thought it was curious that this import worked just fine. I am using the default configuration for a Next.js project set up with create-next-app

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Not sure if this is your case, but if the top folder is in the root directory, you can use this

import { myUtil } from './lib/utils'

I'm guessing that's what's happening, even though you don't have the period in yours.

about 4 years ago · Juan Pablo Isaza Report
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!