Skip to content
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

(/guides/basic-rbac): update code examples for Next 15; resolve a few minor issues; update copy #1669

Merged

Conversation

royanger
Copy link
Member

@royanger royanger commented Oct 30, 2024

DOCS-9468

Explanation:

Updated the code examples to be consistent and work with Next 15 and @clerk/nextjs v6

Copy link

Hey, here’s your docs preview: https://clerk.com/docs/pr/1669

@OwaisSiddiqui
Copy link

I think there is an error in the commits after working on my code:

I think it should change from await clerk.users to await client.users under Admin tools section (since it's now const client = await clerkClient()).

@royanger
Copy link
Member Author

I think there is an error in the commits after working on my code:

I think it should change from await clerk.users to await client.users under Admin tools section (since it's now const client = await clerkClient()).

Good catch. I fixed that.

@royanger royanger marked this pull request as ready for review November 13, 2024 05:49
@royanger royanger requested a review from a team as a code owner November 13, 2024 05:49

1. Navigate to your `app/admin/page.tsx` file.
1. Replace the code with the following code.
1. Replace the code in your `app/admin/page.tsx` file with the following code. It checks whether a search parameter has been appended to the URL by the search form. If a search parameter is present, it queries for users matching the entered term. If one or more users are found, the component displays a list of users, showing their first and last names, primary email address, and current role. Each user has `Make Admin` and `Make Moderator` buttons, which include hidden inputs for the user ID and role. These buttons use the `setRole()` server action to update the user's role.

```tsx {{ filename: 'app/admin/page.tsx' }}
Copy link
Member

Choose a reason for hiding this comment

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

This example is giving a type error! I think the actions need to return void or Promise<void>, but the actions are returning an object with a message property.

Screenshot 2024-11-13 at 17 30 27

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you share your tsconfig and I can take a look into this.

Copy link
Member

Choose a reason for hiding this comment

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

{
  "compilerOptions": {
    "target": "es5",
    "lib": ["dom", "dom.iterable", "esnext"],
    "allowJs": true,
    "skipLibCheck": true,
    "strict": true,
    "forceConsistentCasingInFileNames": true,
    "noEmit": true,
    "esModuleInterop": true,
    "module": "esnext",
    "moduleResolution": "node",
    "resolveJsonModule": true,
    "isolatedModules": true,
    "jsx": "preserve",
    "incremental": true,
    "plugins": [
      {
        "name": "next"
      }
    ],
    "paths": {
      "@/*": ["./*"]
    }
  },
  "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
  "exclude": ["node_modules"]
}

Copy link
Member Author

Choose a reason for hiding this comment

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

I just pushed a commit that resolves this on my end. Let me know if you're still seeing errors.

Copy link
Member

Choose a reason for hiding this comment

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

yeah it still gives me those type errors, but if you are saying you don't have the type errors then it should be fine!

Copy link
Member Author

Choose a reason for hiding this comment

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

Can you share your repo? The errors should be gone. There is either something in your repo (and maybe still in this code that I didn't update) or there is something that is suppressing the errors in my editor.

Copy link
Member

Choose a reason for hiding this comment

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

It is this repo: aa-clerk-next-app
but I made a repo based off of our updated demo repo, and it works with no errors https://github.com/alexisintech/aa-clerk-nextjs-demo2

Copy link
Member

Choose a reason for hiding this comment

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

so I wouldn't worry about it!

Copy link
Contributor

Choose a reason for hiding this comment

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

I also got the same errors. After I wrapped the form actions in async and await the functions, everything works.

@alexisintech alexisintech changed the title refacter: Updated code examples for Next 15 and to resolve a few minor issues (/guides/basic-rbac): update code examples for Next 15; resolve a few minor issues; update copy Nov 13, 2024
@alexisintech
Copy link
Member

I think this is good to go whenever! @royanger

@alexisintech alexisintech merged commit d7c4365 into main Nov 18, 2024
3 checks passed
@alexisintech alexisintech deleted the roy/docs-9468-update-page-protection-section-of-rbac-guide branch November 18, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants