Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
119 changes: 119 additions & 0 deletions contributing/CONTRIBUTING-COMPONENTS-HOOKS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Contributing to Clerk's hooks and components documentation

Component and hook documentation includes SDK-specific code examples and supporting content for all supported SDKs to ensure the best user experience. Each component and hook must have code examples for each supported SDK. If you're adding a new component or hook, or updating an existing one, the sections below outline the process.

<details open="open">
<summary><strong>Table of contents</strong></summary>

- [Contributing to Clerk's hooks and components documentation](#contributing-to-clerks-hooks-and-components-documentation)
- [Components](#components)
- [How component documentation works](#how-component-documentation-works)
- [How to update component documentation](#how-to-update-component-documentation)
- [Hooks](#hooks)
- [How hook documentation works](#how-hook-documentation-works)
- [How to update hook documentation](#how-to-update-hook-documentation)

</details>

## Components

All existing components are listed in the [Component Reference overview](https://clerk.com/docs/reference/components/overview), and live under [`docs/reference/components`](/docs/reference/components) within our docs. Each component belongs to a specific category (except for `<ClerkProvider>`), and these categories determine how components are organized in both the sidebar and the reference overview. **Therefore, it's important to ensure that the ordering in the sidebar matches the ordering in the reference overview**.

### How component documentation works

A component page _usually_ includes the following:

- An image of the component at the top.
- A description of the component.
- An SDK-specific code example showing how to use the component, with an explanation.
- A list of any optional properties the component accepts, rendered via the [`<Properties>`](https://github.com/clerk/clerk-docs/blob/main/CONTRIBUTING.md#properties-1) component.
- Any additional information.

### How to update component documentation

**All component documentation is directly maintained in this repository.**

If you have to make any changes to the components documentation, here are two common scenarios you may encounter:

- If **you need to add a new component** to the docs:

- Add the component to the [Component Reference overview](https://clerk.com/docs/reference/components/overview) under its corresponding category.
- Add the component to the sidebar under the same category.
- Include an image of the component at the top of the page, in both SVG and PNG formats. You can request image assets from the Design team by contacting them directly or by creating a ticket in their [Linear board](https://linear.app/clerk/team/DSN/all). Learn [how to add images to the docs](./CONTRIBUTING.md#images-and-static-assets).
- Provide SDK-specific code examples for each supported SDK, using the [`<If>`](https://github.com/clerk/clerk-docs/blob/main/CONTRIBUTING.md#if-) component. **Avoid examples that only show the import statement.**
- Place all code examples **before** the properties documentation (if applicable).

- If **a component is now supported by an additional SDK**, update the [`sdk`](https://github.com/clerk/clerk-docs/blob/main/CONTRIBUTING.md#sdk) property in the frontmatter of that component's page and add the appropriate code example using `<If>`. For updates to existing code examples, simply modify the relevant example in place.

## Hooks

All existing hooks are listed in the [Hooks Reference overview](https://clerk.com/docs/reference/hooks/overview), and live under [`docs/reference/hooks`](/docs/reference/hooks) within our docs.

### How hook documentation works

A hook page _usually_ includes the following:

- A description of the hook.
- A `Parameters` section, listing the parameters the hook accepts.
- A `Returns` section, listing the properties the hook returns.
- SDK-specific code examples showing how to use the hook, with explanations.
- Any additional information.

> [!NOTE]
> Unlike component documentation, hook documentation is split between two sources. This is intentional, and reflects how we handle type information versus written content. Historically, many hook pages were fully generated from JSDoc + Typedoc, including code examples. However, adding examples for multiple SDKs through Typedoc required significant restructuring of the `clerk/javascript` repo, so we shifted to a hybrid model.

Each hook page contains two distinct layers:

#### Typedoc-generated content

The parameters, return types, and type definitions for each hook are autogenerated from [JSDoc comments](https://jsdoc.app/about-getting-started) in the `clerk/javascript` repo. Typedoc converts these comments into MDX output, which lives in `clerk-docs` in the `clerk-typedoc/` folder. These MDX files are embedded via the [`<Typedoc />`](https://github.com/clerk/clerk-docs/blob/main/CONTRIBUTING.md#typedoc-) component. You can learn more about this process in [this section](https://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md#authoring-typedoc-information).

> [!IMPORTANT]
> When working locally, Typedoc output lives in `/local-clerk-typedoc` instead.

For example, in the `/reference/hooks/use-auth.mdx` file, if you want to render `./clerk-typedoc/clerk-react/use-auth-params.mdx`, you would embed the `<Typedoc />` component like this:

```mdx
<Typedoc src="clerk-react/use-auth-params" />
```

#### Handwritten content

Explanations, usage notes, and SDK-specific code examples live directly in the `clerk-docs` repository. This makes it easier to improve or expand documentation without touching the SDK source or Typedoc configuration.

> [!NOTE]
> Code examples should demonstrate how to use the hook in a real scenario. Avoid examples that only show the import statement.

This split ensures:

- Type information always stays in sync with the SDK source.
- Contributors can freely update explanations or add SDK-specific examples without modifying the Typedoc pipeline.

### How to update hook documentation

Because hook pages combine two sources, updates may need to happen in two places:

- The [javascript](https://github.com/clerk/javascript) repository, when adding or updating parameters, return types, or type definitions through JSDoc.
- The [clerk-docs](https://github.com/clerk/clerk-docs) repository, when adding or updating explanations, SDK-specific code examples, or any other written content.

If you need to update **parameters or return types** for a hook, the changes must be made in the `clerk/javascript` repo:

- Most hooks live under the `packages/shared` folder, except for three hooks - `useAuth`, `useSignIn`, and `useSignup` - who live under the `packages/react` folder.
- Each hook's source file includes interfaces or types made visible via JSDoc comments.
- You can add, remove, or update properties and descriptions directly in these JSDoc comments.

When embedding Typedoc output for a hook in the docs, the package you import from inside the `clerk-typedoc` folder depends on where that hook is exported from in the `clerk/javascript` repo. Use the following mapping:

- If the hook is exported from `packages/react/src/hooks/index.ts`, **import its Typedoc output from the `clerk-react` package**, with the exception of `useOrganization`, `useOrganizationList`, and `useReverification`. Here's how the import would look like:

```mdx
<Typedoc src="clerk-react/<FILENAME>" />
```

- If the hook is exported from `packages/shared/src/react/hooks/index.ts`, **import its Typedoc output from the `shared` package**, as such:

```mdx
<Typedoc src="shared/<FILENAME>" />
```

This ensures that when you embed a Typedoc block (e.g., parameters or returns), you load the correct MDX file.
50 changes: 50 additions & 0 deletions CONTRIBUTING.md → contributing/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,56 @@

Thanks for being willing to contribute to [Clerk's documentation](https://clerk.com/docs)! This document outlines how to effectively contribute to the documentation content located in this repository. See the [style guide](./styleguides/STYLEGUIDE.md) for more information on our guidelines for writing content.

If you're contributing specifically to our hooks and components documentation, please refer to the [dedicated guide](./CONTRIBUTING-COMPONENTS-HOOKS.md).

<details open="open">
<summary><strong>Table of contents</strong></summary>

- [Contributing to Clerk's documentation](#contributing-to-clerks-documentation)
- [Written in MDX](#written-in-mdx)
- [Project setup](#project-setup)
- [Creating an issue](#creating-an-issue)
- [Creating a pull request](#creating-a-pull-request)
- [Preview your changes](#preview-your-changes)
- [Previewing changes locally (for Clerk employees)](#previewing-changes-locally-for-clerk-employees)
- [Validating your changes](#validating-your-changes)
- [Getting your contributions reviewed](#getting-your-contributions-reviewed)
- [Deployment](#deployment)
- [Repository structure](#repository-structure)
- [Sidenav](#sidenav)
- [Update the SDK selector](#update-the-sdk-selector)
- [Add a new SDK](#add-a-new-sdk)
- [Add an external SDK](#add-an-external-sdk)
- [Update the 'key' of an SDK](#update-the-key-of-an-sdk)
- [Editing content](#editing-content)
- [File metadata](#file-metadata)
- [Metadata](#metadata)
- [Search](#search)
- [SDK](#sdk)
- [Headings](#headings)
- [Code blocks](#code-blocks)
- [Highlighting](#highlighting)
- [Collapsing sections of code](#collapsing-sections-of-code)
- [TypeScript type for code block props](#typescript-type-for-code-block-props)
- [Code block shortcodes](#code-block-shortcodes)
- [Prettier integration](#prettier-integration)
- [`<Steps />`](#steps-)
- [Callouts](#callouts)
- [`<CodeBlockTabs />`](#codeblocktabs-)
- [`<Tabs />`](#tabs-)
- [Tooltips](#tooltips)
- [`<TutorialHero />`](#tutorialhero-)
- [`<Cards>`](#cards)
- [`<Properties>`](#properties-1)
- [`<Include />`](#include-)
- [`<Typedoc />`](#typedoc-)
- [`<If />`](#if-)
- [`<Accordion />`](#accordion-)
- [Images and static assets](#images-and-static-assets)
- [Help wanted!](#help-wanted)

</details>

## Written in MDX

Clerk's documentation content is written in a variation of markdown called [MDX](https://mdxjs.com/). MDX allows us to embed React components in the content, unlocking rich, interactive documentation experiences. Clerk's documentation site also supports [GitHub Flavored Markdown](https://github.github.com/gfm/), adding support for things like tables and task lists.
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/customizing-clerk/localization.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ Clerk's localizations are customer-sourced and we encourage customers to add or

1. Fork the [https://github.com/clerk/javascript/](https://github.com/clerk/javascript/) repo.
1. Clone it locally to edit it.
1. Review Clerk's [Contributing](https://github.com/clerk/javascript/blob/main/docs/CONTRIBUTING.md) guide.
1. Review Clerk's [Contributing](https://github.com/clerk/javascript/blob/main/docs/contributing/CONTRIBUTING.md) guide.
1. If you are updating an existing localization locate the file in `packages/localizations/src`
1. If you are adding a new language, copy the `en-US.ts` file and name it according to your language. The naming is the abbreviated language-region. For example, for French in Canada, it would be `fr-CA.ts.`
1. Go through the file and edit the entries.
Expand Down