electron/docs/api/synopsis.md

45 lines
1.4 KiB
Markdown
Raw Normal View History

2014-05-05 06:49:05 +00:00
# Synopsis
2015-05-23 19:41:36 +00:00
All of [node.js's built-in modules](http://nodejs.org/api/) are available in
2015-04-16 03:31:12 +00:00
Electron, and third-party node modules are fully supported too (including the
[native modules](../tutorial/using-native-node-modules.md)).
2014-05-05 06:49:05 +00:00
2015-04-16 03:31:12 +00:00
Electron also provides some extra built-in modules for developing native
desktop applications. Some modules are only available on the main process, some
are only available on the renderer process, and some can be used on both processes.
2014-05-10 01:17:10 +00:00
The basic rule is: if a module is GUI or low-level system related, then it should
be only available on the main process. You need to be familiar with the concept of
[main process vs. renderer process](../tutorial/quick-start.md#the-main-process)
scripts to be able to use those modules.
2014-05-05 06:49:05 +00:00
The main process script is just like a normal `node.js` script:
2014-05-05 06:49:05 +00:00
```javascript
var app = require('app');
var BrowserWindow = require('browser-window');
var window = null;
app.on('ready', function() {
window = new BrowserWindow({width: 800, height: 600});
window.loadUrl('https://github.com');
});
```
2014-05-10 01:17:10 +00:00
The web page is no different than a normal web page, except for the extra
2014-05-05 06:49:05 +00:00
ability to use node modules:
```html
<!DOCTYPE html>
<html>
<body>
<script>
var remote = require('remote');
console.log(remote.require('app').getVersion());
</script>
</body>
</html>
```
To run your app, read [Run your app](../tutorial/quick-start.md#run-your-app).