Skip to content

Commit 6f50555

Browse files
committed
docs(project): explain import from private registries (#18251)
remoteId: rem_01jwbtfqhbbam07z9j9m0etng6 remoteUpdateId: grupd_01k6ar3wt9ps64dqc9v1rfhgch branchName: main commitSha: aec2775cf1d1e6a79a47be1a128c8312c54c8d5b commitUrl: Redocly/redocly@aec2775
1 parent 584beff commit 6f50555

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

docs/realm/customization/import-npm-library.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,57 @@ If you are working in Reunite, you can install the library by adding it to the `
3131
Follow the steps in [Run a specific version in Reunite](../get-started/upgrade-realm-version.md#run-a-specific-version-in-reunite)
3232
to create a `package.json` file if you don't have one already.
3333

34+
## Configure private registries
35+
36+
If you need to install libraries from private NPM registries (such as Artifactory, AWS CodeArtifact, or GitHub Packages), you can configure registry access using either `.npmrc` or `bunfig.toml` files.
37+
38+
### Use `.npmrc`
39+
40+
Create a `.npmrc` file in your project root:
41+
42+
```text
43+
@myorg:registry=https://registry.myorg.com/
44+
//registry.myorg.com/:_authToken=${NPM_TOKEN}
45+
```
46+
47+
### Use `bunfig.toml` (recommended)
48+
49+
For enhanced flexibility, create a `bunfig.toml` file in your project root:
50+
51+
```toml
52+
[install.scopes]
53+
# Using environment variables for credentials
54+
"@myorg" = { token = "$NPM_TOKEN", url = "https://registry.myorg.com/" }
55+
56+
# Alternative with username/password
57+
"@mycompany" = {
58+
username = "$NPM_USERNAME",
59+
password = "$NPM_PASSWORD",
60+
url = "https://registry.mycompany.com/"
61+
}
62+
```
63+
64+
### Secure credential management
65+
66+
{% admonition type="warning" %}
67+
Never commit registry credentials directly to your repository.
68+
Always use environment variables for sensitive information like tokens, usernames, and passwords.
69+
{% /admonition %}
70+
71+
Store your registry credentials as environment variables:
72+
73+
- For local development, add them to your `.env` file (do not commit secrets to Git):
74+
```text
75+
NPM_TOKEN=your-private-token-here
76+
NPM_USERNAME=your-username
77+
NPM_PASSWORD=your-password
78+
```
79+
80+
- For Reunite projects, add them through the **Settings** > **Environment variables** page and mark them as secrets.
81+
Reunite supports environment variable names that start with `NPM_` for private package registries.
82+
83+
For more information about managing environment variables, see **[Environment variables](../reunite/project/env-variables.md)**.
84+
3485
## Import and use components
3586

3687
After installation, you can import components directly in your React files, as in the following example:
@@ -110,5 +161,6 @@ You can use the icon component in your Markdoc files, as in the following exampl
110161

111162
## Resources
112163

164+
- **[Environment variables](../reunite/project/env-variables.md)** - Configure secure credentials for private registry access using environment variables
113165
- **[Build custom Markdoc tags](./build-markdoc-tags.md)** - Create reusable Markdoc components using imported NPM libraries for enhanced functionality
114166
- **[Built-in icon components](../content/markdoc-tags/icon.md)** - Use Redocly's built-in icon system and learn patterns for extending it with external icon libraries

0 commit comments

Comments
 (0)