A robust SQLite-based session storage solution for GramJS Telegram client. Persist your Telegram sessions across restarts with enterprise-grade reliability.
- 🗄️ Persistent Storage - Sessions survive application restarts
- 🔄 Multiple Sessions - Manage multiple accounts in single database
- 📤 Export/Import - Backup and restore
.session
files - ⚡ High Performance - Built on better-sqlite3
- 🛡️ Type Safe - Full TypeScript support
- 🔧 Automatic Management - No manual saving required
npm install telegram-sqlite-session
import { TelegramClient } from 'telegram';
import { SqliteSession } from 'telegram-sqlite-session';
// Create session with SQLite backend
const session = new SqliteSession('./sessions.db', 'my_bot');
// Initialize Telegram client
const client = new TelegramClient(session, apiId, apiHash);
// Authenticate (only needed once)
await client.start({
phoneNumber: async () => '+1234567890',
phoneCode: async () => await prompt('Enter verification code: '),
onError: err => console.error(err),
});
// Session is automatically persisted to database!
console.log('✅ Session saved to SQLite database');
// Manage multiple accounts
const user1Session = new SqliteSession('./sessions.db', 'user1');
const user2Session = new SqliteSession('./sessions.db', 'user2');
const client1 = new TelegramClient(user1Session, apiId, apiHash);
const client2 = new TelegramClient(user2Session, apiId, apiHash);
We welcome contributions! Please read our contributing guidelines before submitting pull requests.
- Fork the repository
- Clone your fork
git clone https://github.com/soorq/telegram-sqlite-session.git
cd telegram-sqlite-session
- Install dependencies
npm install
- Build the project
npm run build
- Run in development mode
npm run dev
MIT © Soorq