Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: cf47cbe262
Fetching contributors…

Cannot retrieve contributors at this time

103 lines (77 sloc) 4.264 kB

Basic Usage

// get app object using the module system
var app = require('appjs');

// server files from the content directory relative to this .js file
app.serveFilesFrom(__dirname + '/content');

// app is the window factory. windows begin loading immediately
var window = app.createWindow();

// when ready is emitted the window has morphed into browser global window
window.on('ready', function(){;


App is the entry point to AppJS. It is the access point for appjs generated interfaces, application lifecycle, events, and in-process serving of files and routes to the browser.

  • app.serveFilesFrom(path): Set path to serve static files from when the browser requests from http://appjs/*
  • app.createWindow(options): Creates a new hidden browser window with the given options and returns it. This window will begin loading immediately if it has a url to go to.

Window Creation Options

Most of these options are adjustable after window creation. They are all optional with the defaults shown below.

  • width = 640
  • height = 460
  • left = centered
  • top = centered
  • name = auto-generated, it's only used to identify the window on
  • url = 'http://appjs' - serve static file root and routers
  • autoResize = false - resizes in response to html content
  • showChrome = true - show border and title bar
  • resizable = false - control if users can resize window
  • disableSecurity = true - allow cross origin requests
  • opacity = 1 - flat percent opacity for window
  • alpha = false - per-pixel alpha blended (Win & Mac)
  • fullscreen = false - client area covers whole screen
  • icons = {} - window icon in tray/taskbar/titlebar


Window objects are created and returned by app.createWindow. A window object will itself be the global object of the browser contect once the page has loaded. If the page loads a new url the same window object will morph to the uninitialized state and then become the new browser global when it is ready.

Window Events

  • window.on('create') - window has been created and is ready for the first time
  • window.on('ready') - window context is ready to use, including browser global
  • window.on('close') - window has been closed entirely and has ceased to exist
  • window.on('minimize') - window was just minimized
  • window.on('maximize') - window was just maximized
  • window.on('fullscreen') - window was just fullscreened
  • window.on('restore') - window was just restored
  • window.on('move') - window was just moveed
  • window.on('resize') - window was just resized


Most of the controls to control the browser container are found on window.frame. window.frame is always available, whether the browser's global context is current initialized or not.

Frame Properties

  • window.frame.left - integer
  • - integer
  • window.frame.width - integer
  • window.frame.height - integer
  • window.frame.opacity - float between 0 and 1
  • window.frame.title - string
  • window.frame.state - one of ['normal', 'maximized', 'minimized', 'fullscreen']
  • window.frame.resizable - boolean
  • window.frame.autoResize - boolean
  • window.frame.showChrome - boolean
  • window.frame.alpha - boolean
  • window.frame.topmost - boolean

Frame Methods

  • window.frame.fullscreen()
  • window.frame.minimize()
  • window.frame.maximize()
  • window.frame.restore()
  • window.frame.hide()
  • window.frame.resize(width, height)
  • window.frame.move(left, top, [width], [height])
  • window.frame.fade(toOpacity, milliseconds, callback)
  • window.frame.drag() - (Windows only currently)
  • window.frame.openDevTools()
  • window.frame.closeDevTools()

Debugging tips

On Windows plateform, you can launch your application in a console:

bin\node.exe --harmony app.js

Do not forget you can open Chrome Console using a line of javascript :

Jump to Line
Something went wrong with that request. Please try again.