Introduction
This is a step-by-step tutorial to create a website similar to Hacker News using Tribe react sdk.
1. Create a community#
If you don't have a community yet, you should create one on Tribe. In this tutorial we will use ReactSDK Tutorial community.
2. Generate an access token#
First you need to generate an access token for the logged in member or guest. You can generate it directly using our GraphQL API or JavaScript SDK. You will then need to provide this token to use React SDK. You can simply generate a guest token for ReactSDK Tutorial community and continue this tutorial. You will be able to use the data already in the community, but some parts of this tutorial (e.g. posting news) requires logged-in token.
3. Create a react project#
You can follow Create React App to create a new React project with typescript. Alternatively, if you already have a React project you can add Tribe ReactSDK on top of it.
4. Install the React SDK#
You can simply install Tribe React SDK using the following yarn command:
note
We have to install @tribeplatform/gql-client because we will use it in this tutorial.
After installing your package.json should look similar to this.
5. Inject Tribe React provider#
Wrap your App by TribeProvider. Here is how index.tsx should look like.
Now you have set up the project with Tribe ReactSDK, and it's ready to use.