A web app to browse the contents of npm or GitHub Registry packages — file tree, syntax-highlighted source files, README, and more.
- Client: React + Vite + TypeScript
- Server: Express + TypeScript
- Syntax highlighting: Shiki (
github-darktheme) - Auth: GitHub OAuth (with manual token fallback)
The app uses GitHub OAuth to authenticate users and access private GitHub Registry packages.
-
Go to GitHub → Settings → Developer settings → OAuth Apps (direct link: https://github.com/settings/developers)
-
Click "New OAuth App"
-
Fill in the form:
Field Value Application name GitHub Package Visualizer(or anything you like)Homepage URL http://localhost:5173Authorization callback URL http://localhost:3001/api/auth/callbackThe callback URL must match exactly — it points to the Express server, not the Vite dev server.
-
Click "Register application"
-
On the next page, copy the Client ID. Then click "Generate a new client secret" and copy the secret immediately (it won't be shown again).
Create server/.env:
GITHUB_CLIENT_ID=your_client_id_here
GITHUB_CLIENT_SECRET=your_client_secret_herenpm install
npm run devThis starts both the Vite dev server (port 5173) and the Express API (port 3001) concurrently.
Open http://localhost:5173 in your browser.
- The user clicks "Se connecter avec GitHub" in the UI.
- The browser navigates to
http://localhost:3001/api/auth/login, which redirects to GitHub's OAuth authorization page. - After the user grants access, GitHub redirects to
http://localhost:3001/api/auth/callback?code=.... - The server exchanges the code for an access token and redirects back to the client with the token in the URL fragment (
#access_token=...). - The client reads the token from the fragment, stores it in
localStorageunder the keygh_access_token, and uses it for all subsequent API calls.
The token is passed in the URL fragment (not the query string) so it is never sent to the server by the browser.
If you don't want to set up an OAuth app, you can use a personal access token directly:
- Go to GitHub → Settings → Developer settings → Personal access tokens → Tokens (classic)
- Generate a token with the
read:packagesscope - In the app's search page, click "Utiliser un token manuellement" and paste your token
github-package-visualizer/
├── package.json # root — runs client + server with concurrently
├── client/ # Vite + React + TypeScript
│ └── src/
│ ├── App.tsx
│ ├── api/index.ts
│ ├── hooks/useGitHubAuth.ts
│ └── components/
│ ├── SearchBar.tsx
│ ├── VersionPicker.tsx
│ ├── FileTree.tsx
│ ├── FileViewer.tsx
│ └── GitHubAuthButton.tsx
└── server/ # Express + TypeScript
├── .env # GITHUB_CLIENT_ID + GITHUB_CLIENT_SECRET (not committed)
└── src/
├── index.ts
├── routes/
│ ├── auth.ts # OAuth login / callback / user
│ └── package.ts # metadata / download / file / cache
└── services/
└── packageService.ts
- Downloaded packages are cached in the OS temp directory (
os.tmpdir()/pkg-visualizer-cache/<name>@<version>/). The cache is reused on subsequent loads as long as the directory is non-empty. - The Vite dev server proxies
/api/*requests tohttp://localhost:3001. The OAuth login redirect must point directly to the Express server (http://localhost:3001/api/auth/login) because browser redirects bypass the Vite proxy.