3.1.6 • Published 12 days ago

@weaverse/hydrogen v3.1.6

Weekly downloads
-
License
MIT
Repository
github
Last release
12 days ago

@weaverse/hydrogen

Overview

@weaverse/hydrogen is a crucial package within the Weaverse ecosystem, designed to facilitate the integration of Shopify Hydrogen and Remix projects with the Weaverse CMS. It leverages @weaverse/react for rendering content and provides a client for easy setup and data fetching from Weaverse CMS.

Key Features

  • Weaverse Client Integration: Enables seamless integration with Weaverse CMS, allowing for efficient data fetching and rendering in Hydrogen/Remix projects.
  • Dynamic Data Fetching: Fetch and render page data and global theme settings server-side, ensuring dynamic and consistent content delivery.
  • Component Registration and Rendering: Register React components with Weaverse and render them using the WeaverseHydrogenRoot component.
  • Flexible Schema Definition: Define behavior and interactivity of components within Weaverse Studio through the HydrogenComponentSchema.
  • Customizable Input Settings: Specify configurations for merchant-customizable component settings in Weaverse Studio.

Installation

npm install @weaverse/hydrogen

Setup and Usage

Weaverse Client Setup

Initialize the Weaverse Client to establish a connection between your Hydrogen project and Weaverse CMS:

// <root>/server.ts

import { createWeaverseClient } from '~/weaverse/create-weaverse.server'

const handleRequest = createRequestHandler({
  // ...
  getLoadContext: () => ({
    // Injecting the Weaverse client into the loader context.
    weaverse: createWeaverseClient({
      storefront,
      request,
      env,
      cache,
      waitUntil,
    }),
    // ... more app context properties
  }),
})

Data Fetching and Rendering

Use the Weaverse Client to fetch data such as page content and global theme settings:

// <root>/app/routes/($locale)._index.tsx

import { json } from '@shopify/remix-oxygen'
import { type RouteLoaderArgs } from '@weaverse/hydrogen'

export async function loader({ context }: RouteLoaderArgs) {
  let { weaverse } = context

  return json({
    // The key prop for a Weaverse page must always be `weaverseData`
    weaverseData: await weaverse.loadPage(),
    // Additional page data...
  })
}

Implement the WeaverseHydrogenRoot component to render the fetched content:

// <root>/app/weaverse/index.tsx

import { WeaverseHydrogenRoot } from '@weaverse/hydrogen'
import { GenericError } from '~/components/GenericError'
import { components } from './components'

export function WeaverseContent() {
  return (
    <WeaverseHydrogenRoot
      components={components}
      errorComponent={GenericError}
    />
  )
}

// <root>/app/routes/($locale)._index.tsx

import { WeaverseContent } from '~/weaverse'

export default function Homepage() {
  return <WeaverseContent />
}

Defining Component Schema

Define your component's schema to control its behavior and interactivity within Weaverse Studio:

import type { HydrogenComponentSchema } from '@weaverse/hydrogen'

export let schema: HydrogenComponentSchema = {
  title: 'Product Card',
  type: 'product-card',
  inspector: [
    {
      group: 'Settings',
      inputs: [], // Defining input settings
    },
  ],
  childTypes: ['image', 'product-title', 'price'],
  presets: {
    type: 'product-card',
    children: [{ type: 'image' }, { type: 'product-title' }, { type: 'price' }],
  },
  limit: 3,
  enabledOn: {
    pages: ['INDEX', 'PRODUCT', 'ALL_PRODUCTS'],
    groups: ['body'],
  },
  toolbar: ['general-settings', ['duplicate', 'delete']],
}

Customizing Input Settings

Customize input settings for merchant-adjustable component configurations in Weaverse Studio:

{
  type: "select",
  label: "Image aspect ratio",
  name: "imageAspectRatio",
  configs: {
    options: [
      { value: "auto", label: "Adapt to image" },
      { value: "1/1", label: "1/1" },
      { value: "3/4", label: "3/4" },
      { value: "4/3", label: "4/3" },
    ]
  },
  defaultValue: "auto"
}

Contributing

Contributions to the @weaverse/hydrogen package are highly appreciated. Please refer to our contributing guidelines for more details on how to contribute effectively.

License

This package is created by The Weaverse Team (https://weaverse.io) and is licensed under the MIT License.

3.1.6

12 days ago

3.1.5

13 days ago

3.1.4

15 days ago

3.1.3

18 days ago

3.1.2

18 days ago

3.1.1

29 days ago

3.1.0

1 month ago

3.0.1

2 months ago

3.0.0

2 months ago

2.10.3

3 months ago

2.10.2

3 months ago

2.10.1

3 months ago

2.10.0

4 months ago

2.9.0

4 months ago

2.8.12

4 months ago

2.8.11

4 months ago

2.8.9

4 months ago

2.8.10

4 months ago

2.8.8

4 months ago

2.8.6

5 months ago

2.8.5

5 months ago

2.8.3

5 months ago

2.8.2

5 months ago

2.8.4

5 months ago

2.8.1

5 months ago

2.8.0

5 months ago

2.4.1

6 months ago

2.4.0

6 months ago

2.4.3

6 months ago

2.4.2

6 months ago

2.7.1-pre.2

6 months ago

2.7.1-pre.1

6 months ago

2.7.1-pre.0

6 months ago

1.5.0

7 months ago

2.3.0

7 months ago

1.4.1

7 months ago

2.2.0

7 months ago

2.2.2

7 months ago

2.2.5

7 months ago

1.3.3

8 months ago

1.3.2

8 months ago

1.3.1

8 months ago

2.1.2

7 months ago

2.1.1

7 months ago

2.1.0

7 months ago

1.2.0

8 months ago

1.2.2

8 months ago

1.2.1

8 months ago

1.0.62

9 months ago

1.0.61

9 months ago

2.6.4-pre.1

6 months ago

1.0.60

10 months ago

2.6.4-pre.0

6 months ago

1.0.65

9 months ago

1.0.64

9 months ago

1.0.63

9 months ago

2.0.1

7 months ago

2.0.0

7 months ago

1.1.1

9 months ago

1.1.0

9 months ago

1.1.9

9 months ago

1.1.8

9 months ago

1.1.7

9 months ago

1.1.6

9 months ago

1.1.5

9 months ago

1.1.4

9 months ago

1.1.3

9 months ago

2.7.0

6 months ago

2.7.2

5 months ago

2.7.1

6 months ago

1.1.12

8 months ago

1.1.11

8 months ago

1.1.10

9 months ago

1.1.16

8 months ago

1.1.15

8 months ago

1.1.14

8 months ago

1.1.13

8 months ago

1.1.19

8 months ago

1.1.17

8 months ago

1.0.55

10 months ago

1.0.54

10 months ago

1.0.53

10 months ago

1.1.20

8 months ago

1.0.59

10 months ago

1.0.58

10 months ago

1.0.57

10 months ago

1.0.56

10 months ago

2.6.1

6 months ago

2.6.0

6 months ago

2.6.3

6 months ago

2.6.2

6 months ago

2.7.4

5 months ago

2.5.0

6 months ago

2.5.1

6 months ago

0.7.33

1 year ago

0.7.32

1 year ago

0.7.34

1 year ago

0.7.31

1 year ago

0.7.30

1 year ago

0.7.37

1 year ago

0.7.39

1 year ago

0.7.38

1 year ago

0.7.22

2 years ago

0.7.21

2 years ago

0.7.24

1 year ago

0.7.23

1 year ago

0.7.20

2 years ago

0.7.26

1 year ago

0.7.25

1 year ago

0.7.28

1 year ago

0.7.27

1 year ago

1.0.39

12 months ago

1.0.38

12 months ago

0.7.19

2 years ago

0.7.18

2 years ago

0.7.15

2 years ago

0.7.14

2 years ago

0.7.17

2 years ago

0.7.16

2 years ago

1.0.40

12 months ago

1.0.44

12 months ago

1.0.43

12 months ago

1.0.42

12 months ago

1.0.41

12 months ago

1.0.48

11 months ago

1.0.47

11 months ago

1.0.46

12 months ago

1.0.45

12 months ago

1.0.49

11 months ago

1.0.51

11 months ago

1.0.50

11 months ago

1.0.52

11 months ago

1.0.19

1 year ago

1.0.2

1 year ago

1.0.18

1 year ago

1.0.1

1 year ago

1.0.17

1 year ago

1.0.0

1 year ago

1.0.16

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

0.7.71

1 year ago

0.7.70

1 year ago

1.0.26

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

0.7.66

1 year ago

1.0.29

1 year ago

0.7.65

1 year ago

1.0.28

1 year ago

0.7.68

1 year ago

1.0.27

1 year ago

0.7.67

1 year ago

0.7.62

1 year ago

0.7.61

1 year ago

0.7.64

1 year ago

0.7.63

1 year ago

0.7.69

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

0.7.60

1 year ago

1.0.30

1 year ago

1.0.37

12 months ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.34

1 year ago

0.7.55

1 year ago

0.7.54

1 year ago

0.7.57

1 year ago

0.7.56

1 year ago

0.7.51

1 year ago

0.7.50

1 year ago

0.7.53

1 year ago

0.7.52

1 year ago

0.7.59

1 year ago

0.7.58

1 year ago

0.7.44

1 year ago

0.7.43

1 year ago

0.7.45

1 year ago

0.7.40

1 year ago

0.7.42

1 year ago

0.7.41

1 year ago

0.7.48

1 year ago

0.7.47

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

0.7.13

2 years ago

0.7.12

2 years ago

0.7.11

2 years ago

0.7.10

2 years ago

0.7.9

2 years ago

0.7.8

2 years ago

0.7.7

2 years ago

0.7.6

2 years ago

0.7.5

2 years ago

0.7.2

2 years ago

0.7.1

2 years ago

0.7.0

2 years ago

0.6.30

2 years ago

0.6.29

2 years ago

0.6.28

2 years ago

0.6.27

2 years ago

0.6.26

2 years ago

0.6.23

2 years ago

0.6.22

2 years ago

0.6.21

2 years ago

0.6.20

2 years ago

0.6.19

2 years ago

0.6.18

2 years ago

0.6.17

2 years ago

0.6.16

2 years ago

0.6.13

2 years ago

0.6.12

2 years ago

0.6.11

2 years ago