← Back to infernojs/inferno

How to Deploy & Use infernojs/inferno

InfernoJS Deployment and Usage Guide

Prerequisites

  • Runtime Requirements: Inferno v9 requires the following JavaScript features to be present in the executing runtime:

    • Promise
    • String.prototype.includes()
    • String.prototype.startsWith()
    • Array.prototype.includes()
    • Object.spread()
    • for ... of
  • Node.js: Required for development and building (version 12 or higher recommended)

  • Package Manager: npm or yarn for dependency management

  • Browser Support: Inferno is actively tested on modern browsers. For older browser support, consider using polyfills.

Installation

  1. Clone the Repository:

    git clone https://github.com/infernojs/inferno.git
    cd inferno
    
  2. Install Dependencies:

    npm install
    # or
    yarn install
    
  3. Install Build Tools (if needed for development):

    npm install -g @swc/cli
    # or for Babel
    npm install -g @babel/cli @babel/core
    

Configuration

Environment Variables

No specific environment variables are required for basic usage. For development, you may need to configure:

  • Test Environment: Inferno uses Sauce Labs for browser testing. You may need to set up Sauce Labs credentials if running tests locally.

Build Configuration

Inferno supports multiple JSX compilers:

  • SWC Plugin: For SWC-based compilation
  • Babel Plugin: For Babel-based compilation
  • TS Plugin: For TypeScript compilation

Choose your preferred compiler and configure it in your build setup.

Build & Run

Development

  1. Start Development Server:

    npm run dev
    # or
    yarn dev
    
  2. Run Tests:

    npm test
    # or
    yarn test
    

Production Build

  1. Build for Production:

    npm run build
    # or
    yarn build
    
  2. Run Production Server:

    npm start
    # or
    yarn start
    

Examples

The repository includes several example applications:

  • UI Bench: Performance benchmarking
  • DBMonster: Real-time data visualization
  • Animations: Component animation examples

To run examples, navigate to the respective directories and follow their specific instructions.

Deployment

Static Hosting (Recommended)

Inferno applications can be deployed as static files:

  1. Build Your Application:

    npm run build
    
  2. Deploy to Static Hosting Services:

    • Vercel: vercel --prod
    • Netlify: Drag and drop the dist folder
    • GitHub Pages: Configure GitHub Actions to deploy to gh-pages branch

Server-Side Rendering

For SSR applications:

  1. Install Inferno Server:

    npm install inferno-server
    
  2. Configure Your Server:

    • Use Node.js with Express or similar frameworks
    • Implement server-side rendering using inferno-server

Platform Recommendations

  • Vercel/Netlify: For static Inferno applications
  • AWS Amplify: For scalable static hosting
  • Heroku/Cloud Run: For server-side rendered applications
  • Cloudflare Workers: For edge-side rendering

Troubleshooting

Common Issues and Solutions

  1. Browser Compatibility Issues

    • Problem: Application doesn't work in older browsers
    • Solution: Add polyfills for required runtime features (Promise, String methods, etc.)
  2. Build Errors

    • Problem: Build fails with JSX compilation errors
    • Solution: Ensure you have the correct JSX compiler plugin installed (SWC, Babel, or TS plugin)
  3. Performance Issues

    • Problem: Application is slow with large DOM trees
    • Solution: Use Inferno's optimization features like linkEvent, proper key usage, and compile-time flags
  4. Testing Issues

    • Problem: Tests fail in certain browsers
    • Solution: Check Sauce Labs browser matrix and ensure your tests are compatible with supported browsers
  5. Missing Dependencies

    • Problem: Cannot find module errors
    • Solution: Run npm install or yarn install to ensure all dependencies are installed
  6. Animation Issues

    • Problem: Animations not working as expected
    • Solution: Verify you're using the correct animation lifecycle methods (componentDidAppear, componentWillDisappear, etc.)

Performance Optimization Tips

  • Use linkEvent to avoid unnecessary re-renders
  • Implement shouldComponentUpdate for expensive components
  • Use Inferno's controlled components for input/select/textarea elements
  • Leverage compile-time optimizations with JSX flags

Development Tips

  • Use the Inferno DevTools extension for debugging
  • Monitor render counts to identify performance bottlenecks
  • Test with the UI Bench and DBMonster examples to benchmark performance

For more detailed information, refer to the Inferno documentation and the GitHub repository.