---
title: Getting Started
description: Get started with NoLag in 5 minutes. Learn how to connect, subscribe to topics, and publish messages.
---

# Getting Started

Get up and running with NoLag in under 5 minutes.

## Prerequisites

- A NoLag account ([sign up free](https://portal.nolag.app))
- Node.js 18+ (for JavaScript SDK)
- A project and app created in the NoLag dashboard

## Step 1: Install the SDK

Install the NoLag SDK for your preferred language:

```typescript [npm]
npm install @nolag/js-sdk
```
```python [pip]
pip install nolag
```
```go [go get]
go get github.com/NoLagApp/nolag-go
```

## Step 2: Get Your Access Token

1. Log in to the [NoLag Dashboard](https://portal.nolag.app)
2. Navigate to your project
3. Go to **Actors** section
4. Create a new Actor and copy the access token

## Step 3: Connect to NoLag

```typescript [TypeScript]
import { NoLag } from '@nolag/js-sdk'

// Create client and connect
const client = NoLag('your_access_token')
await client.connect()

console.log('Connected to NoLag!')
```
```python [Python]
from nolag import NoLag

# Create client and connect
client = NoLag('your_access_token')
await client.connect()

print('Connected to NoLag!')
```
```go [Go]
package main

import (
    "fmt"

    nolag "github.com/NoLagApp/nolag-go"
)

func main() {
    // Create client and connect
    client := nolag.New("your_access_token")
    client.Connect()

    fmt.Println("Connected to NoLag!")
}
```

## Step 4: Subscribe to a Topic

Topics are channels for messages. Subscribe to receive messages published to a topic:

```typescript [TypeScript]
// Set up app and room, then subscribe
const room = client.setApp('my-app').setRoom('general')
room.subscribe('messages')

// Listen for messages
room.on('messages', (data) => {
  console.log('Received:', data)
})
```
```python [Python]
# Set up app and room, then subscribe
room = client.set_app('my-app').set_room('general')
await room.subscribe('messages')

# Listen for messages
def handle_message(data, meta):
    print('Received:', data)

room.on('messages', handle_message)
```
```go [Go]
import "fmt"

// Set up app and room, then subscribe with handler
room := client.SetApp("my-app").SetRoom("general")
room.Subscribe("messages", func(data any, meta nolag.MessageMeta) {
    fmt.Println("Received:", data)
})
```

## Step 5: Publish a Message

Publish messages to a topic for all subscribers to receive:

```typescript [TypeScript]
// Publish a message
room.emit('messages', {
  text: 'Hello, World!',
  sender: 'user-123',
  timestamp: Date.now()
})
```
```python [Python]
# Publish a message
await room.emit('messages', {
    'text': 'Hello, World!',
    'sender': 'user-123',
    'timestamp': time.time()
})
```
```go [Go]
// Publish a message
room.Emit("messages", map[string]any{
    "text":      "Hello, World!",
    "sender":    "user-123",
    "timestamp": time.Now().Unix(),
})
```

## Complete Example

Here's a complete example in your preferred language:

```typescript [TypeScript]
import { NoLag } from '@nolag/js-sdk'

// Connect to NoLag
const client = NoLag('your_access_token')
await client.connect()

// Set up app and room
const room = client.setApp('my-app').setRoom('general')

// Subscribe to a topic
room.subscribe('messages')

// Listen for messages
room.on('messages', (data) => {
  console.log('Received:', data)
})

// Publish a message
room.emit('messages', { text: 'Hello, World!' })
```
```python [Python]
from nolag import NoLag

# Connect to NoLag
client = NoLag('your_access_token')
await client.connect()

# Set up app and room
room = client.set_app('my-app').set_room('general')

# Subscribe to a topic
await room.subscribe('messages')

# Listen for messages
def handle_message(data, meta):
    print('Received:', data)

room.on('messages', handle_message)

# Publish a message
await room.emit('messages', {'text': 'Hello, World!'})
```
```go [Go]
package main

import (
    "fmt"

    nolag "github.com/NoLagApp/nolag-go"
)

func main() {
    // Connect to NoLag
    client := nolag.New("your_access_token")
    client.Connect()

    // Set up app and room
    room := client.SetApp("my-app").SetRoom("general")

    // Subscribe to a topic with message handler
    room.Subscribe("messages", func(data any, meta nolag.MessageMeta) {
        fmt.Println("Received:", data)
    })

    // Publish a message
    room.Emit("messages", map[string]string{"text": "Hello, World!"})
}
```

## Next Steps

- [Learn about Topics & Pub/Sub](/docs/concepts/topics)
- [Understand Presence Tracking](/docs/concepts/presence)
- [Configure Quality of Service](/docs/concepts/qos)
- [Full JavaScript SDK Reference](/docs/sdks/javascript)
