Explore the docs
.
View codesandbox Demo
·
Report Bug
·
Request Feature/Example
- Read the docs
- Look into other examples to learn how to spawn a Helia node in Node.js and in the Browser
- Visit https://dweb-primer.ipfs.io to learn about IPFS and the concepts that underpin it
- Head over to https://proto.school to take interactive tutorials that cover core IPFS APIs
- Check out https://docs.ipfs.io for tips, how-tos and more
- See https://blog.ipfs.io for news and more
- Need help? Please ask 'How do I?' questions on https://discuss.ipfs.io
Make sure you have installed all of the following prerequisites on your development machine:
- Git - Download & Install Git. OSX and Linux machines typically have this already installed.
- Node.js - Download & Install Node.js and the npm package manager.
> npm install
> npm start
Then open your browser to http://localhost:8888.
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.
The page you will see is broken up into 4 sections:
- The intro: title and global variables you can play with in your browser console
- 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()
andhelia.stop()
respectively. - Updated content (look for
nodeUpdateInterval =
insrc/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
PeerId
s will render if the count is > 0.
- Helia will start up on page load. You can use the 'Start Helia' and 'Stop Helia' to call
- Suggestions: Try out these code snippets in your browser terminal, in order.
- 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
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.
- Fork the IPFS Project
- Create your Feature Branch (
git checkout -b feature/amazing-feature
) - Commit your Changes (
git commit -a -m 'feat: add some amazing feature'
) - Push to the Branch (
git push origin feature/amazing-feature
) - Open a Pull Request
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