question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible for build/index.html to function in browser without the need of a server (double click from file location) ?

See original GitHub issue

Hi everyone,

I’m struggling to find the solution to this issue I’m having with create-react-app. After running npm build I want to be able to open the index.html from build folder, in browser with ‘doubleclick’ from file location, without the need of npm or any server. I also want my routes and functionality of the app to work in this scenario, basically to have my client see the app without having to use any server. I’ve been doing some research on the matter but couldn’t find much. I would like to know if it’s possible and if anyone has any links or even solutions to share in case I’m missing something. I’m rather new to react and your help will mean a lot. I’m using ubuntu 17. My route in App.js looks like so :

class App extends React.Component {
  render(){
    return(
      <Router basename="/">
        <Switch>
            <Route exact path="/" component={LoginComponent}/>
            <Route path="/app" component={AppLayout}/>
        </Switch>
      </Router>
    );
  }
}

then my index.js looks like so:

ReactDOM.render(<App />, document.getElementById('root'));

After running npm run build and open build/index.html in browser it shows nothing. After inspecting I can see the <div id="root"> being there but displaying only the comment <!-- react-empty: 1 -->.

Any help would be greatly appreciated Many thanks in advance.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

15reactions
mbowen13commented, Oct 3, 2017

@gaearon Why do you need to serve it? Why can’t you just open build/index.html to view in the browser?

3reactions
smartworld-dmcommented, Feb 22, 2018

With the serve -s build the site works correctly in prod But when I click the index.html, the browser shows the blank page. React script doesn’t work.

Read more comments on GitHub >

github_iconTop Results From Across the Web

I'm using create-react-app and I need to open build/index.html ...
I'm trying to get the app working in browser without using any kind of server. Just by opening index.html from build folder in...
Read more >
Is there an advantage to running code on a localhost as ...
Is there an advantage to running code on a localhost as opposed to simply double clicking on the HTML file? I have previously...
Read more >
How to manually start a localhost version of WebGL build
1. Open the WebGL build output directory with VS Code. 2. Right-click index.html, and select "Open with Live Server". ( ...
Read more >
The Simplest Ways to Handle HTML Includes | CSS-Tricks
I'm talking about straight up includes, like taking a chunk of HTML and plopping it right into another. For example the use case...
Read more >
Introduction to automated testing - Learn web development
Use a browser automation system like Selenium to run specific tests ... let's first create a test directory to allow us to play...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found