Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@amagaki/amagaki-engine-preact

Package Overview
Dependencies
Maintainers
2
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@amagaki/amagaki-engine-preact

[![NPM Version][npm-image]][npm-url] [![TypeScript Style Guide][gts-image]][gts-url]

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

amagaki-engine-preact

NPM Version TypeScript Style Guide

An Amagaki plugin for using Preact (TSX) for template rendering. Supports server-side rendering (SSR) and (optionally) hydration.

This engine can be used to bring React into an Amagaki project with minimal overhead, and you can choose whether to also use it on your site's frontend. Page modules can be created entirely using React components (via Preact) and integrate seamlessly with frontend components also built in React.

Usage

  1. Install the plugin. This plugin is meant to be used in conjunction with @amagaki/amagaki-plugin-page-builder.
npm install --save \ 
  @amagaki/amagaki-engine-preact \
  @amagaki/amagaki-plugin-page-builder
  1. Add to amagaki.ts.
import {PageBuilder} from '@amagaki/amagaki-plugin-page-builder';
import {Pod} from '@amagaki/amagaki';
import {PreactEnginePlugin} from '../src';

export default (pod: Pod) => {
  PreactEnginePlugin.register(pod);
  PageBuilder.register(pod, {
    partialPaths: {
      css: ['/dist/css/${partial.partial}/${partial.partial}.css'],
      js: ['/dist/js/partials/${partial.partial}/${partial.partial}.js'],
      view: ['/src/partials/${partial.partial}/${partial.partial}.tsx'],
    },
  });
};
  1. If your partial requires hydration:

    a. Add to your frontend's main.tsx.

    import {PartialHydrator} from '@amagaki/amagaki-engine-preact';
    
    // Import all partials that require hydration.
    import Hero from './partials/Hero';
    
    PartialHydrator.register({
      components: {
        'Hero': Hero,
      },
    });
    

    b. Ensure includeContext: true is supplied in YAML files for any partial that requires hydration.

    partials:
    - partial: Hero
      includeContext: true
      headline: Hello World!
    

FAQs

Package last updated on 11 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc