# InterPlanetary Name System (IPNS)

IPFS uses content-based addressing; it creates an address of a file based on data contained within the file. Unfortunately, having a long string of seamingly random letters and numbers isn't great if you're trying to host a website or share a link. If you were to share the IPFS addresses /ipfs/QmbezGequPwcsWo8UL4wDF6a8hYwM1hmbzYv2mnKkEWaUp with someone, not only is it hard to read, but you need to give the person a new link everytime you update the content.

The InterPlanetary Name System (IPNS) solves these issues by creating human-readable addresses that can be updated.

A name in IPNS is the hash of a public key. It is associated with a record containing information about the hash it links to that is signed by the corresponding private key. New records can be signed and published at any time.

When looking up an IPNS address, use the /ipns/ prefix:


# Example IPNS Setup

Imagine you want to publish your website under IPFS. You can use the Files API to publish your static website, and then you'll get a CID you can link to. But when you need to make a change, a problem arises: you get a new CID because you now have different content. And it is not possible for you to be always giving others the new address.

Here's where the Name API comes in handy. With it, you can create a single, stable IPNS address that points to the CID for the latest version of your website.

// The address of your files.
const addr = '/ipfs/QmbezGequPwcsWo8UL4wDF6a8hYwM1hmbzYv2mnKkEWaUp'

ipfs.name.publish(addr, function (err, res) {
    // You now receive a res which contains two fields:
    //   - name: the name under which the content was published.
    //   - value: the "real" address to which Name points.

In the same way, you can republish a new version of your website under the same address. By default, ipfs.name.publish will use the Peer ID.

# Alternatives to IPNS

IPNS is not the only way to create mutable addresses on IPFS. You can also use DNSLink, which is currently much faster than IPNS and also uses more readable names. Other community members are exploring ways to use blockchains to store common name records.