Create a Post
This guide will walk you through the process of creating a Post.
Your First Post
Lens Post content, including text, images, videos, and more, is stored in what's known as Post Metadata. This metadata is a JSON file linked to the Lens Post via its public URI.
To create a Post on Lens, follow these steps:
Create the Post Metadata object.
Upload this object to a publicly accessible URI.
Use this metadata URI to create the Lens Post.
See the Lens Metadata Standards guide for more information on creating and hosting Metadata objects.
First, construct a Post Metadata object with the necessary content.
- TS/JS
- JSON Schema
The Post Metadata Standard encompass various types of content. Below is a list of the most common ones.
- Text-Only
- Audio
- Image
- Video
- Article
- Others
Used to describe content that is text-only, such as a message or a comment.
Text-only
import { textOnly } from "@lens-protocol/metadata";
const metadata = textOnly({ content: `GM! GM!`,});
See textOnly(input): TextOnlyMetadata reference doc.
Then, upload the Post Metadata object to a public URI.
import { textOnly } from "@lens-protocol/metadata";import { uploadJson } from "./my-upload-lib";
const metadata = textOnly({ content: `GM! GM!`,});
const contentUri = await uploadJson(metadata); // e.g., lens://4f91ca…
- GraphQL
- React
- TypeScript
Then, you can use the post mutation to create a Lens Post.
You MUST be authenticated as Account Owner or Account Manager to make this request.
See below examples for creating a Post, Comment, and Quote.
Finally, handle the result as explained in the Transaction Lifecycle guide.
Post Rules
Coming soon.
Post Actions
Coming soon.