Skip to content

Latest commit

 

History

History
 
 

helia-script-tag

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Helia logo

Using Helia via <script/> tags from CDN


Explore the docs . View codesandbox Demo · Report Bug · Request Feature/Example

Table of Contents

About The Project

Getting Started

Prerequisites

Make sure you have installed all of the following prerequisites on your development machine:

Installation and Running example

> npm install
> npm start

Then open your browser to http://localhost:8888.

Usage

This example is basic demo and proof of concept for using helia via script tags. Other examples use build-scripts that may be too complicated for your needs. If you have a website where you manage your dependencies via script tags in an HTML file, you may benefit from looking at this example instead of the others at https://github.com/ipfs-examples/helia-examples/tree/main/examples.

If you are seeing errors like ERR_REQUIRE_ESM or ERR_PACKAGE_PATH_NOT_EXPORTED when trying to use this example, please check out /examples/helia-cjs instead.

The main areas of focus should be two files: index.html and src/index.js.

If you're confused about what the different methods under 'Some Suggestions' are doing, you may want to check out helia-101 for a full breakdown of the code.

Using the example

The page you will see is broken up into 4 sections:

  1. The intro: title and global variables you can play with in your browser console
  2. Node Status: The status of the helia node, which is updated every 500ms
    • Helia will start up on page load. You can use the 'Start Helia' and 'Stop Helia' to call helia.start() and helia.stop() respectively.
    • Updated content (look for nodeUpdateInterval = in src/index.js to change or edit what's updated):
      • Node Status - shows either "Online" or "Offline".
      • ID - Shows the PeerId of your Helia node.
      • Discovered Peers - The count of peers discovered. Check the event log at the bottom of the page to see their IDs.
      • Connected Peers - The count of peers your helia node is connected to. Also, a list of their PeerIds will render if the count is > 0.
  3. Suggestions: Try out these code snippets in your browser terminal, in order.
  4. Event Log: Elapsed-TimeStamped messages showing you some of what Helia and it's managed libp2p node are doing. This event log shows:
    • instantiation of the libp2p instance passed to helia
    • instantiation of the Helia node
    • peer discovery
    • peer connection
    • peer disconnection

For more examples, please refer to the Documentation

Documentation

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the IPFS Project
  2. Create your Feature Branch (git checkout -b feature/amazing-feature)
  3. Commit your Changes (git commit -a -m 'feat: add some amazing feature')
  4. Push to the Branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Want to hack on IPFS?

The IPFS implementation in JavaScript needs your help! There are a few things you can do right now to help out:

Read the Code of Conduct and JavaScript Contributing Guidelines.

  • Check out existing issues The issue list has many that are marked as 'help wanted' or 'difficulty:easy' which make great starting points for development, many of which can be tackled with no prior IPFS knowledge
  • Look at the Helia Roadmap This are the high priority items being worked on right now
  • Perform code reviews More eyes will help a. speed the project along b. ensure quality, and c. reduce possible future bugs
  • Add tests. There can never be enough tests