### Install Kubo RPC Client Source: https://github.com/ipfs/js-kubo-rpc-client/blob/main/README.md Install the library using npm. This is the primary method for adding the client to your project. ```bash npm i kubo-rpc-client ``` -------------------------------- ### Create Kubo RPC client instance from CDN in browser Source: https://github.com/ipfs/js-kubo-rpc-client/blob/main/README.md Example of creating an IPFS client instance in a web browser after loading the library from a CDN. Demonstrates connecting with explicit host/port or relying on window properties. ```javascript const ipfs = window.KuboRpcClient.create({ host: 'localhost', port: 5001 }) // If you omit the host and port, the client will parse window.host const ipfs = window.KuboRpcClient.create() ``` -------------------------------- ### Configure and run IPFS daemon Source: https://github.com/ipfs/js-kubo-rpc-client/blob/main/README.md Commands to check and set the IPFS API port in the configuration, and to start the daemon. Ensure the API port is correctly configured before interacting with the client. ```sh # Show the ipfs config API port to check it is correct > ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # Set it if it does not match the above output > ipfs config Addresses.API /ip4/127.0.0.1/tcp/5001 # Restart the daemon after changing the config # Run the daemon > ipfs daemon ``` -------------------------------- ### Import and create Kubo RPC client instance Source: https://github.com/ipfs/js-kubo-rpc-client/blob/main/README.md Demonstrates various ways to import the `create` function and instantiate the IPFS client, connecting to a local daemon via default, multiaddr, options, or specific API paths. ```javascript import { create } from 'kubo-rpc-client' // connect to ipfs daemon API server const ipfs = create('http://localhost:5001') // (the default in Node.js) // or connect with multiaddr const ipfs = create('/ip4/127.0.0.1/tcp/5001') // or using options const ipfs = create({ host: 'localhost', port: '5001', protocol: 'http' }) // or specifying a specific API path const ipfs = create({ host: '1.1.1.1', port: '80', apiPath: '/ipfs/api/v0' }) ``` -------------------------------- ### Add Data to IPFS Source: https://github.com/ipfs/js-kubo-rpc-client/blob/main/README.md Example of adding data to IPFS using the 'add' method. This operation returns an object containing the content identifier (CID). ```javascript // call Core API methods const { cid } = await client.add('Hello world!') ```