Skip to content

(docs: nextjs QS) fix incorrect title; update convexclientprovider explanation #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

alexisintech
Copy link
Contributor

@alexisintech alexisintech commented Mar 14, 2025

Clerk employee here 👋 While checking out the Convex docs to see how to integrate Convex into a Clerk + Next.js app, I noticed the Next.js QS could use some love. From the Clerk Docs team to yours 💜

Notes about the changes:

  • This all actually started as just a title change, I saw "Create a React app" and I was like, well actually you're creating a Next.js app. So I went to open a PR, and was like, well while I'm here, I'll just update a few more things...
  • Organize order of events sequentially, for better UX. E.g. "in the convex/ folder" should be the lead of a sentence, because its the first in a sequence of events. A user will first need to go to their convex/ folder to then create a new file; it's the first step so it should be the first direction given in the sentence.
  • The colon change in and the export name: `api.tasks.get`.. It originally read as the export name, `api.tasks.get`. which grammatically was telling me that the export name was api.tasks.get which I was really confused by. When I finally got to the end of the QS, I learned that the API function itself is what's called api.tasks.get and then I understood what the doc was trying to convey. So I've made a small change to help understandability.
  • Updated the explanation of creating a provider wrapper. I feel the copy was telling me what the code was doing syntactically, but the code speaks for itself. That's why there's an example paired with the copy! So instead, the copy here should be explaining what the code is doing. I updated the explanation to the best of my ability, and to how it made sense to me, but if the explanation is incorrect then of course, feel free to update.

Also, I'm surprised you don't abstract the ConvexClientProvider part away for users so they can skip the step of creating it themselves and simply import it from Convex itself and then wrap their app (similar to how we do ClerkProvider). 👀

Cheers 😸💖


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link
Contributor

@thomasballinger thomasballinger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I'll land this, expect to see it out later today

@@ -133,8 +130,9 @@ version of this quickstart.
</Step>

<Step title="Create a client component for the Convex provider">
Add a new file <JSDialectFileName name="ConvexClientProvider.tsx" /> in the `app/` folder. Include the `"use client";` directive, create a
`ConvexReactClient` and a component that wraps its children in a `ConvexProvider`.
For `<ConvexProvider>` to work on the client, `<ConvexReactClient>` must be passed to it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For `<ConvexProvider>` to work on the client, `<ConvexReactClient>` must be passed to it.
For `<ConvexProvider>` to work on the client, `ConvexReactClient` must be passed to it.

Comment on lines +69 to +70
package, which provides a convenient interface for working
with Convex.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
package, which provides a convenient interface for working
with Convex.
package.

agree "from a React app" wasn't very useful, and now the rest doesn't seem useful either IMO

`ConvexReactClient` and a component that wraps its children in a `ConvexProvider`.
For `<ConvexProvider>` to work on the client, `<ConvexReactClient>` must be passed to it.

In the `app/` folder, add a new file <JSDialectFileName name="ConvexClientProvider.tsx" /> with the following code. This creates a component that wraps `<ConvexProvider>` and passes it the `<ConvexReactClient>`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the `app/` folder, add a new file <JSDialectFileName name="ConvexClientProvider.tsx" /> with the following code. This creates a component that wraps `<ConvexProvider>` and passes it the `<ConvexReactClient>`.
In the `app/` folder, add a new file <JSDialectFileName name="ConvexClientProvider.tsx" /> with the following code. This creates a client component that wraps `<ConvexProvider>` and passes it the `<ConvexReactClient>`.

@@ -172,7 +170,7 @@ version of this quickstart.
</Step>

<Step title="Start the app">
Start the app, open [http://localhost:3000](http://localhost:3000) in a browser,
Run your development server, open [http://localhost:3000](http://localhost:3000) in a browser,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since "development server" is an overloaded term in convex I'll add "Next.js" or "frontend" here

@thomasballinger
Copy link
Contributor

So instead, the copy here should be explaining what the code is doing

love it

@thomasballinger
Copy link
Contributor

Also, I'm surprised you don't abstract the ConvexClientProvider part away for users so they can skip the step of creating it themselves and simply import it from Convex itself and then wrap their app (similar to how we do ClerkProvider).

Yeah good point, we held off to avoid needing to create Next.js-specific code using the (at the time only used by) Next.js "use client" directives with the goal of keeping the convex package very general; but now that we have some Next.js-specific code in convex/nextjs it seems like time to do this! The Clerk nextjs package has been helpful to look at for how to build great libraries that work well with Next.js.

Maybe soon! This isn't the only way to set this up Convex providers with Clerk but it seems reasonable to make the common path easier.

@thomasballinger
Copy link
Contributor

Landed in 85fe152

Thanks @alexisintech!

@alexisintech
Copy link
Contributor Author

alexisintech commented Mar 18, 2025

Landed in 85fe152

Thanks @alexisintech!

woah what did you do to get it into that commit??

also, love all the helpful communication and openness to accepting these updates ❤️ thanks so much :)

@thomasballinger
Copy link
Contributor

thanks for sharing the motivation behind these changes, gives us some positive second order effects from teaching in addition to the specific improvements!

we're using copybara to get code between our open source repo and the closed-source one, which unfortunately means the PR shows as Closed instead of Merged here but at least does preserve authorship via Co-authored-by:

@alexisintech
Copy link
Contributor Author

awesome! i've never seen that, its so cool

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants