⚡
light
  • light
  • guides
    • getting started
    • server vs serverless
    • routes
    • models
    • factories
    • routing
    • plugins
    • middleware
    • query
    • params
    • global
    • error handling
    • hot module reloading (TODO)
    • databases (TODO)
      • mongoose
      • objection/knex
    • testing (TODO)
      • ava
      • jest
    • deployments (TODO)
      • runkit
      • aws
      • now
      • heroku
      • server
      • google cloud
      • azure
      • netlify
    • misc (TODO)
      • apollo/graphql
  • api
    • server({ routes, opts }): object
    • params(path, url): Promise<object>
    • boom
      • Coming soon
    • micro
      • Coming soon
      • Coming soon
      • Coming soon
      • Coming soon
      • Coming soon
      • Coming soon
Powered by GitBook
On this page
  • Prerequisites
  • Install
  • Usage
  • Conclusion

Was this helpful?

  1. guides

getting started

Prerequisites

  • Node >= 8.0.0

  • NPM >= 5.0.0

Install

Install light

npm install light

and add the dev script to your package.json.

{
  // ...
  "scripts": {
    "start": "light start",
    "dev": "light dev"
  }
  // ...
}

Usage

Once you've installed light, all .js files under the routes folder will be used to serve pages.

To get started, populate routes/index.js.

routes/index.js
const { createRoute } = require('light');

const { route } = createRoute('index');

module.exports = route(() => {
  return {
    hello: 'world',
  };
});

Run npm run dev to start the development server. You should see an output in your terminal similar to the one below.

› start      🔥 igniting the server 🔥
› listening  on port 3000
› hmr        starting the hot reloader
› hmr        watching for changes

Conclusion

That's it! You now have a dev server that

  • hot swaps to speed up development routes

  • supports many different serverless and hosting platforms

  • has very little magic behind the scenes, what you see in a route is what you get

Feel free to continue with the guides in the sidebar to understand more of the framework!

PreviouslightNextserver vs serverless

Last updated 5 years ago

Was this helpful?

View your resulting website at !

localhost:3000