This project is a Next.js application that demonstrates interaction with the NEAR Social contract. It allows users to view a social feed and create posts on the NEAR network.
- Connect to NEAR wallet
- View a feed of posts from NEAR Social contract
- Create new posts on NEAR Social contract
- Responsive and intuitive user interface
- Node.js (version 12 or higher)
- npm
- NEAR account
-
Clone the repository:
git clone https://github.com/NEARBuilders/near-social-example.git cd near-social-example
-
Install dependencies:
npm install
(We have been seeing issues with yarn while using limited keys so don't recommend it for the app.)
-
Run the development server:
npm run dev
-
Open http://localhost:3000 with your browser to see the result.
pages/index.js
: Main component with NEAR Social integrationcomponents/PostForm.js
: Form component for creating new postscomponents/PostFeed.js
: Component for displaying the social feedcomponents/SignIn.js
: Sign-in component for NEAR wallet connectioncontext/index.js
: NEAR context providerconfig/index.js
: Configuration values
- Next.js
- @builddao/near-social-js: For interacting with NEAR Social contract
- near-api-js: For NEAR blockchain interactions
This project uses the @builddao/near-social-js
library to interact with the NEAR Social contract. Key functions include:
Social.index()
: Retrieves indexed data from the NEAR Social contract, used here to get the list of postsSocial.get()
: Retrieves specific data from the NEAR Social contract, used here to get the content of each postSocial.set()
: Updates data on the NEAR Social contract, used here to create new posts
These functions are used within the fetchPosts()
and createPost()
methods in the application to interact with the NEAR Social contract.
You can deploy this Next.js app using platforms like Vercel or by following the Next.js deployment documentation.
To learn more about the technologies used in this project:
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.