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

Chore: Improved Install Extensions Page #4461

Merged
merged 2 commits into from
Jan 16, 2025
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
Binary file modified docs/src/pages/docs/_assets/extensions-01.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/src/pages/docs/_assets/extensions-04.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
72 changes: 63 additions & 9 deletions docs/src/pages/docs/install-extensions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,32 @@ keywords:
---

import { Callout } from 'nextra/components'
import { Settings, Plus } from 'lucide-react'


# Install Extensions

Jan comes with several [pre-installed extensions](/docs/extensions#core-extensions) that provide core functionalities. You can manually add custom third-party extensions at your own risk.
Jan uses a modular extension system that allows developers to add new functionality to the application. By default, Jan comes with several [pre-installed extensions](/docs/extensions#core-extensions) that provide core functionalities. You can manually add custom third-party extensions at your own risk.

## Prerequisites

### Required Tools
- Node.js (version 20.0.0 or higher)
- Basic understanding of TypeScript

### Jan's Architecture
Jan is built on:
- **Electron**: Powers the desktop application
- Extensions run in the main process
- Access to Node.js APIs and filesystem
- Cannot use browser-only libraries
- **Next.js**: Handles the user interface
- **Node.js**: Runs extension logic

This architecture means your extensions:
- Can use Node.js packages and system APIs
- Need to handle client/server communication properly
- Should follow Electron's security practices

## Create Extensions

Expand All @@ -31,11 +52,11 @@ Jan currently only accepts `.tgz` file format for extensions.
</Callout>

> **Heads Up:**
> - Please use the following structure and setup as a **reference** only.
> - You're free to develop extensions using any approach or structure that works for your needs. As long as your extension can be packaged as a `.tgz` file, it can be installed in Jan. Feel free to experiment and innovate!
> - Use the following structure and setup as a **reference** only.
> - You're free to develop extensions using any approach or structure that works for your needs. Feel free to experiment and innovate.
> - If you already have your own `.tgz` extension file, please move forward to [install extension](/docs/install-extensions#install-extensions) step.

#### Extension Structure
### Extension Structure
Your extension should follow this basic structure:

```
Expand All @@ -48,7 +69,7 @@ my-extension/
└── README.md # Extension documentation
```

#### Required package.json Fields
### Required package.json Fields
```json
{
"name": "@your-org/extension-name",
Expand All @@ -73,17 +94,50 @@ my-extension/
}
```

#### Example Extension Template
### Example Extension Template

You can find a template for creating Jan extensions in our [example repository](https://github.com/janhq/extension-template).
## Install Extensions

To install a custom extension in Jan:

1. Navigate to [Jan Data Folder](/docs/data-folder):
2. Copy `.tgz` extension file into the extensions directory
3. Extract the `.tgz` file into its own folder under the extensions directory
1. Open Jan, navigate to **Settings** (<Settings width={16} height={16} style={{display:"inline"}}/>) > **Extensions**
2. Click **<Plus width={16} height={16} style={{display:"inline"}}/> Install Extension**
3. Select your extension `.tgz` file & save
4. Restart Jan

After restart, the `~/jan/data/extensions/extensions.json` file will be updated automatically to include your new extension.

<br/>
![Install Extensions](./_assets/extensions-04.png)
<br/>

## Troubleshooting
**Check Extensions Logs**

```bash
# View application logs
~/jan/logs/app.log

# Open Developer Tools
Mac: Cmd + Option + I
Windows/Linux: Ctrl + Shift + I
```
**Common Error Patterns**

1. Initialization Failures
- Extension fails to load/activate
- Verify package.json configuration
- Check extension dependencies

2. Runtime Errors
- Node.js module errors
- API connection issues
- Authentication failures

3. Build Problems
```bash
rm -rf dist/
npm run build
```

Loading