Skip to content

Auto-detect Next.js framework on netlify build #5806

@akd-io

Description

@akd-io

Which problem is this feature request solving?

Netflify's CLI is a bit behind in UX compared to Vercel's CLI.

I'm building Create Next Stack, and I'm having trouble getting the Netlify CLI to auto-detch that my repository is using Next.js when running netlify deploy. If this is correct, it doesn't seem to be possible to deploy a Next.js from the CLI without setting up configuration first. And maybe using the Next.js plugin?

At the moment running netlify deploy in a new Next.js project looks like below.

$ netlify deploy
This folder isn't linked to a site yet
? What would you like to do? +  Create & configure a new site
? Team: my-team
? Site name (leave blank for a random name; you can change it later): my-site

Site Created

Admin URL: https://app.netlify.com/sites/my-site
URL:       https://my-site.netlify.app
Site ID:   8bcd1f3d-27b4-47ae-96dc-93f2ca03b94c

Linked to my-site
Please provide a publish directory (e.g. "public" or "dist" or "."):
/Users/akd/workspace/my-site
? Publish directory /Users/akd/workspace/my-site/.next
Deploy path: /Users/akd/workspace/my-site/.next
Deploying to draft URL...
✔ Finished hashing 
✔ CDN requesting 0 files
✔ Finished uploading 0 assets
✔ Deploy is live!

Build logs:        https://app.netlify.com/sites/my-site/deploys/648a24e53c733202a5f3bd46
Function logs:     https://app.netlify.com/sites/my-site/functions?scope=deploy:648a24e53c733202a5f3bd46
Website draft URL: https://648a24e53c733202a5f3bd46--my-site.netlify.app

If everything looks good on your draft URL, deploy it to your main site URL with the --prod flag.
netlify deploy --prod

When following the link to the build logs, you are met with a broken build, as the CLI didn't detect a Next.js project, and all steps were skipped:

Screenshot 2023-06-14 at 22 40 06

Describe the solution you'd like

I'd like Netflify's CLI to auto-detect Next.js like Vercel's CLI does as follows:

$ vercel
Vercel CLI 30.2.2
? Set up and deploy “~/workspace/create-next-stack-tests/a6
7e4390-1fce-4284-b9a6-0268f8006453”? [Y/n] y
? Which scope do you want to deploy to? my-scope
? Link to existing project? [y/N] n
? What’s your project’s name? my-app
? In which directory is your code located? ./
Local settings detected in vercel.json:
Auto-detected Project Settings (Next.js): <-------------- AUTO-DETECTS HERE
- Build Command: next build
- Development Command: next dev --port $PORT
- Install Command: `yarn install`, `pnpm install`, or `npm install`
- Output Directory: Next.js default
? Want to modify these settings? [y/N] n
🔗  Linked to akd-io/my-app (created .vercel)
🔍  Inspect: https://vercel.com/akd-io/my-app/FAG8CW3nNJQdWNy4VxEdG2RvM1er [2s]
✅  Production: https://my-app.vercel.app [2m]
📝  Deployed to production. Run `vercel --prod` to overwrite later (https://vercel.link/2F).
💡  To change the domain or build command, go to https://vercel.com/akd-io/my-app/settings

Pull request (optional)

  • I can submit a pull request.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: featurecode contributing to the implementation of a feature and/or user facing functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions