{"repo":"sindresorhus/electron-serve","free":true,"listed":false,"github":"https://github.com/sindresorhus/electron-serve","clone":"git clone https://github.com/sindresorhus/electron-serve.git","description":"Static file serving for Electron apps","language":"JavaScript","stars":486,"topics":["electron-module","electron","serve","static-file-server","server","single-page-app","nodejs","npm-package"],"license":"MIT","category":"dev-tools","readme_excerpt":"electron-serve Static file serving for Electron apps Normally you would just use win.loadURL('file://…') , but that doesn't work when you're making a single-page web app, which most Electron apps are today, as history.pushState() 'ed URLs don't exist on disk. It serves files if they exist, and falls back to index.html if not, which means you can use router modules like react-router , vue-router , etc. Install Requires Electron 37 or later. Usage API loadUrl = serve(options?) options Type: object directory Type: string \\ Default: '.' The directory to serve, relative to the app root directory. scheme Type: string \\ Default: 'app' Custom scheme. For example, foo results in your directory being available at foo://- . hostname Type: string \\ Default: '-' Custom hostname. file Type: string \\ Default: 'index' Custom HTML filename. This gets appended with '.html' . isCorsEnabled Type: boolean \\ Default: true Whether CORS should be enabled. Useful for testing purposes. partition Type: string \\ Default: electron.session.defaultSession The partition where the protocol should be installed, if not using Electron's default partition. loadUrl(window, searchParameters?) The serve function returns a loadUrl function, which you use to serve your HTML file in that window. window Required \\ Type: BrowserWindow The window to load the file in. searchParameters Type: object URLSearchParams Key value pairs or an URLSearchParams instance to set as the search parameters. Notes ES modules support ES mo","default_branch":null,"files":null,"tree":[],"storefront":"/r/sindresorhus","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sindresorhus/electron-serve/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}