All Projects → schmich → connect-browser-sync

schmich / connect-browser-sync

Licence: MIT License
Connect middleware for BrowserSync

Programming Languages

javascript
184084 projects - #8 most used programming language
HTML
75241 projects

Projects that are alternatives of or similar to connect-browser-sync

Http Proxy Middleware
⚡ The one-liner node.js http-proxy middleware for connect, express and browser-sync
Stars: ✭ 8,730 (+54462.5%)
Mutual labels:  middleware, connect, browser-sync
tailwindcss-postcss-browsersync-boilerplate
Tailwind CSS + PostCSS + BrowserSync boilerplate
Stars: ✭ 28 (+75%)
Mutual labels:  browsersync, browser-sync
access-log
PSR-15 middleware to generate access logs
Stars: ✭ 21 (+31.25%)
Mutual labels:  middleware
AkamaiOPEN-edgegrid-php-client
PHP client library for Akamai {OPEN} EdgeGrid Authentication scheme (based on Guzzle)
Stars: ✭ 38 (+137.5%)
Mutual labels:  middleware
redux-tools
Redux tools to speed up development.
Stars: ✭ 16 (+0%)
Mutual labels:  middleware
http-authentication
PSR-15 middleware to implement Basic and Digest Http authentication
Stars: ✭ 29 (+81.25%)
Mutual labels:  middleware
polix
🚀 Node.js Web Framework
Stars: ✭ 32 (+100%)
Mutual labels:  middleware
ASPNETcoreAngularJWT
Angular in ASP.NET Core with JWT solution by systemjs
Stars: ✭ 48 (+200%)
Mutual labels:  middleware
Android
Connect IM Android Project
Stars: ✭ 21 (+31.25%)
Mutual labels:  connect
middleman-gulp
A Middleman 4 template using Gulp.js via the external pipeline
Stars: ✭ 42 (+162.5%)
Mutual labels:  browsersync
redux-global-loader
A Redux middleware for global loader
Stars: ✭ 13 (-18.75%)
Mutual labels:  middleware
DevOps
DevOps code to deploy eScience services
Stars: ✭ 19 (+18.75%)
Mutual labels:  middleware
restana
Super fast and minimalist framework for building REST micro-services.
Stars: ✭ 380 (+2275%)
Mutual labels:  middleware
middleland
Simple PSR-15 middleware dispatcher
Stars: ✭ 31 (+93.75%)
Mutual labels:  middleware
geggleto-acl
PSR-7 Zend ACL implementation - Permission Library [ slim, psr7, acl, permissions, zend ]
Stars: ✭ 33 (+106.25%)
Mutual labels:  middleware
oryx
.NET Cross platform and highly composable middleware for building web request handlers in F#
Stars: ✭ 178 (+1012.5%)
Mutual labels:  middleware
cute
An event-centric publisher/subscribe model for objects inspired by the Qt framework
Stars: ✭ 37 (+131.25%)
Mutual labels:  middleware
react-redux-api-tools
A set of tools to facilitate react-redux development and decouple logic from compontents
Stars: ✭ 37 (+131.25%)
Mutual labels:  middleware
ReSwiftMonitor
ReSwift+redeux dev tools
Stars: ✭ 13 (-18.75%)
Mutual labels:  middleware
NiFi4Trading
NiFi Bundle for FIX Protocol
Stars: ✭ 14 (-12.5%)
Mutual labels:  middleware

connect-browser-sync

Connect middleware for BrowserSync.

Use this middleware to automatically inject the necessary BrowserSync <script> tags into your HTML pages. Alternatively, you can integrate BrowserSync with your app using Gulp or Grunt.

NPM version Build Status

Usage

Assuming you will only use BrowserSync in development:

npm install browser-sync --save-dev
npm install connect-browser-sync --save-dev
// app.js
var express = require('express');
var app = express();

// Other configuration...

if (app.get('env') === 'development') {
  var browserSync = require('browser-sync');
  var bs = browserSync.create().init({ logSnippet: false });
  app.use(require('connect-browser-sync')(bs));
}


// Routes and handlers...

See the BrowserSync API docs for initialization options.

Notes

  • You must use version 2.0.0 or greater of the browser-sync package.
  • The app.use statement must come before any handlers that you want to integrate with BrowserSync. This includes both dynamic route handlers and static asset handlers.
  • Injection only happens on responses with a Content-Type header of text/html and content containing a </body> or </head> tag.

Compatibility

BrowserSync 1.x

If you need to use BrowserSync 1.x, use version 1.0.2 of this package.

Turbolinks

Turbolinks and BrowserSync can conflict (see turbolinks#147 and browser-sync#977). As a workaround, you can inject the BrowserSync tags into <head> instead.

To inject the tags into <head>, specify { injectHead: true }:

if (app.get('env') === 'development') {
  var browserSync = require('browser-sync');
  var bs = browserSync.create().init({ logSnippet: false });
  app.use(require('connect-browser-sync')(bs, { injectHead: true }));
}

Example

See the example folder.

License

Copyright © 2014 Chris Schmich
MIT License, See LICENSE for details.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].