Next.js: open browser after app started

Created on 27 Apr 2020  ยท  4Comments  ยท  Source: vercel/next.js

Is there plan to add automatically open browser after app started?
This feature is in create-react-app and would be nice to have that too, do you agree?

Nice example:

โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ”‚                                                    โ”‚
โ”‚   Storybook 5.3.18 started                         โ”‚
โ”‚   18 s for manager and 14 s for preview            โ”‚
โ”‚                                                    โ”‚
โ”‚    Local:            http://localhost:9001/        โ”‚
โ”‚    On your network:  http://192.168.0.213:9001/    โ”‚
โ”‚                                                    โ”‚
โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

All 4 comments

We're not planning to add automatically opening the browser at this point (keeping the CLI minimal and features contained).

@timneutkens Hello Tim ๐Ÿ‘‹

What would be the proper way of doing in the current state? I suppose we can do it using a custom server, in the server.listen() callback? Is there any solution without the custom server?

VS Code only:

// .vscode/launch.json

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Chrome",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceRoot}/src",
      "sourceMapPathOverrides": {
        "webpack:///src/*": "${webRoot}/*"
      },
      "preLaunchTask": "npm: dev"
    }
  ]
}
// .vscode/tasks.json

{
  // See https://go.microsoft.com/fwlink/?LinkId=733558
  // for the documentation about the tasks.json format
  "version": "2.0.0",
  "tasks": [
    {
      "type": "npm",
      "script": "dev",
      "group": {
        "kind": "test",
        "isDefault": true
      },
      "isBackground": true, //This prevents the launch.json to wait for the completion of the task
      "problemMatcher": {
        "owner": "custom", //This is not needed but, required by the problemMatcher Object
        "pattern": {
          "regexp": "^$" //This is not needed but, required by the problemMatcher Object
        },
        "background": {
          "activeOnStart": true,
          "beginsPattern": "started server on .*", //Signals the begin of the Task
          "endsPattern": "compiled .*" //Signals that now the initialization of the task is complete
        }
      }
    }
  ]
}

Then press F5

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rauchg picture rauchg  ยท  3Comments

flybayer picture flybayer  ยท  3Comments

formula349 picture formula349  ยท  3Comments

jesselee34 picture jesselee34  ยท  3Comments

pie6k picture pie6k  ยท  3Comments