[PUB-1552] Add Pub/Sub React getting started guide
Description
This PR adds a new getting started guide for Ably Pub/Sub with React.
This getting started guide is intended to replace the existing one at https://ably.com/docs/getting-started/react, which can be found at content/getting-started/react.textile. Due to some issues explained in this comment currently this PR adds a new file react-new.textile for the Pub/Sub React getting started guide.
Resolves PUB-1552
Checklist
- [x] Commits have been rebased.
- [x] Linting has been run against the changed file(s).
- [x] The PR adheres to the writing style guide and contribution guide.
[!IMPORTANT]
Review skipped
Auto reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
🪧 Tips
Chat
There are 3 ways to chat with CodeRabbit:
- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
I pushed a fix in commit <commit_id>, please review it.Explain this complex logic.Open a follow-up GitHub issue for this discussion.
- Files and specific lines of code (under the "Files changed" tab): Tag
@coderabbitaiin a new review comment at the desired location with your query. Examples:@coderabbitai explain this code block.@coderabbitai modularize this function.
- PR comments: Tag
@coderabbitaiin a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.@coderabbitai read src/utils.ts and explain its main purpose.@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.@coderabbitai help me debug CodeRabbit configuration file.
Support
Need help? Create a ticket on our support page for assistance with any issues or questions.
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.
CodeRabbit Commands (Invoked using PR comments)
@coderabbitai pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai generate sequence diagramto generate a sequence diagram of the changes in this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile to the root of your repository. - Please see the configuration documentation for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation:
# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
Documentation and Community
- Visit our Documentation for detailed information on how to use CodeRabbit.
- Join our Discord Community to get help, request features, and share feedback.
- Follow us on X/Twitter for updates and announcements.
So there already exists content/getting-started/react.textile file which renders at https://ably.com/docs/getting-started/react. I couldn't straight up replace it with the new content as there are a bunch of places in the docs that reference that file:
30 results - 12 files
content\getting-started\quickstart.textile:
53: The JavaScript SDK can be used with React and React Native. We also provide a dedicated "React Hooks package.":/docs/getting-started/react
content\getting-started\setup.textile:
42: The JavaScript SDK can be used with React and React Native. We also provide a dedicated "React Hooks package.":/docs/getting-started/react
examples\pub-sub-channel-messages\react\README.md:
15: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
16: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): manages the state and functionality of a specific channel, providing access to messages, members, and realtime interactions within that channel via React context.
17: - [`useChannel()`](/docs/getting-started/react#useChannel) hook: a hook to manage the state and interaction for a channel, allowing users to join, send messages, and listen for messages.
18: - [`publish()`](/docs/getting-started/react#useChannel) function: a function to publish messages to the specified channel.
examples\pub-sub-channel-state\react\README.md:
13: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
14: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): initializes and manages a shared channel instance, passing it down through React context to enable realtime pub/sub functionality across the application.
15: - [`useChannelStateListener`](/docs/getting-started/react#useChannelStateListener): creates a subscriber to be notified of channel state changes.
examples\pub-sub-connection-state\react\README.md:
13: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
examples\pub-sub-history\react\README.md:
15: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
16: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): manages the state and functionality of a specific channel, providing access to messages, history, presence, and realtime interactions within that channel via React context.
17: - [`useChannel()`](/docs/getting-started/react#useChannel) hook: a hook enabling users to subscribe to a channel and receive its messages.
examples\pub-sub-message-encryption\react\README.md:
15: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
16: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): manages the state and functionality of a specific channel, providing access to messages, members, and realtime interactions within that channel via React context. Options are optional with `ChannelProvider`, options such as `cipher` to enable encryption.
17: - [`useChannel()`](/docs/getting-started/react#useChannel) hook: a hook to manage the state and interaction for a channel, allowing users to join, send messages, and listen for messages.
18: - [`publish()`](/docs/getting-started/react#useChannel) function: a function to publish messages to the specified channel.
examples\pub-sub-occupancy\react\README.md:
13: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
14: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): manages the state and functionality of a specific channel, providing access to messages, history, presence, and realtime interactions within that channel via React context. By using channel options to enable occupancy, the channel will automatically update occupancy information.
15: - [`useChannel()`](/docs/getting-started/react#useChannel) hook: a hook enabling users to subscribe to a channel and receive its messages. Whenever the occupancy is updated, the `useChannel()` hook will update the occupancy information.
examples\pub-sub-presence\react\README.md:
15: - [`AblyProvider`](/docs/getting-started/react#ably-provider): initializes and manages a shared pub/sub client instance, passing it down through React context to enable realtime pub/sub functionality across the application.
16: - [`ChannelProvider`](/docs/getting-started/react#channel-provider): manages the state and functionality of a specific channel, providing access to messages, presence, and realtime interactions within that channel via React context.
17: - [`usePresenceListener()`](/docs/getting-started/react#useChannel) hook: a hook to subscribe to presence events on a channel, notifying users when other users enter or leave a presence set, or updates their member data.
18: - [`usePresence()`](/docs/getting-started/react#usePresenceListener) hook: a hook enabling users to enter the presence set.
examples\spaces-component-locking\react\README.md:
21: This example also uses the [`ChannelProvider`](/docs/getting-started/react#channel-provider) and [`useChannel()`](/docs/getting-started/react#useChannel) hook from the core Pub/Sub product in order to publish and subscribe to the changing values of each component.
src\components\SDKsPage\data.ts:
58: setupLink: 'getting-started/react',
163: setupLink: 'getting-started/react',
src\data\nav\pubsub.ts:
41: link: '/docs/getting-started/react',
And even the new Chat getting started guide for React has a reference to it: https://github.com/ably/docs/pull/2521/files#diff-7236fae23c5195699eddce94eb3f8c2f307b171b5f7035c85f974f86db02e9c7R77.
By looking at these references, I can see that the existing React documentation is mostly used as an API reference for hooks and the AblyProvider/ChannelProvider components.
The Chat getting started guide handles similar cases nicely - it provides links such as "ChatClientProvider":https://sdk.ably.com/builds/ably/ably-chat-js/main/typedoc/functions/chat-react.ChatClientProvider.html that point directly to the TypeDoc documentation for Chat React hooks.
Currently, we don't publish ably-js React hooks to TypeDoc (see the latest TypeDoc for v2, which includes only ably and modular). However, if we start generating TypeDoc documentation for ably-js React hooks, we can replace all existing references to the current React guide with links to the new TypeDoc API references. Then, the React guide itself could be replaced with the new content added in this PR.
@ttypic @m-hulbert wdyt?
I do also wonder whether for this type of getting staerted guide it's worth having e.g. a repo in e.g. Ably labs that walks through each step commit by commit?
We used to do this for tutorials but they became unmaintainable. Do you think many people would go through commit-by-commit in this way?
I also removed notes about AblyProvider and ChannelProvider being updated/added in ably-js 2.0 that are currently visible on https://ably.com/docs/getting-started/react:
ably-js 2.0 has been out for a ~year now, I don't think we should still have "new" and "updated" flags
@VeskeR @m-hulbert do we plan to do anything with this?
@jamienewcomb Andrii was going to update to move to Tailwind to match with what we decided with Chat. I don't think he had the chance before vacation.
@jamienewcomb Andrii was going to update to move to Tailwind to match with what we decided with Chat. I don't think he had the chance before vacation.
@m-hulbert I can't see any acknowledgement that he is going to do that on this PR. is that a hard requirement?
@jamienewcomb Andrii was going to update to move to Tailwind to match with what we decided with Chat. I don't think he had the chance before vacation.
@m-hulbert I can't see any acknowledgement that he is going to do that on this PR. is that a hard requirement?
@jamienewcomb to keep them consistent, yes. There's a Slack thread where we've agreed this.
@m-hulbert went back to using Tailwind in https://github.com/ably/docs/pull/2534/commits/33835a10351fc9a854f777ba606dba7c9aba2b1f.
There is last outstanding question regarding existing content/getting-started/react.textile file
I've made small changes to this getting started to bring things more inline with the existing JS getting started guide in terms of layout etc.
I've also moved our react hooks page to react-hooks and renamed the react getting started to react. We will in the near future be updating the docs so there's no need for the react-hooks page.
I would advise we don't merge just yet as need to discuss with marketing and other depts to determine any other links that link to the react hooks page.
@GregHolmes we will leave this with you in that case and mark this ticket as done on our side if that's okay, thanks