Skip to main content

Pikku

Pikku - meaning tiny 🔎 in Finnish - is a minimalistic batteries included framework built around simple functions. It works with any event driven design (currently http, websockets and scheduled tasks) and can be run on any Javascript runtime, currently Cloudflare Workers, Fastify, Bun, AWS Lambda, Express, uWS, WS and others.

import { pikkuFunc, addHTTPRoute } from '#pikku/pikku-types.gen.js'

export const createTodo = pikkuFunc<
{ title: string; description: string },
{ id: string; title: string; createdBy: string }
>(async ({ logger }, data, session) => {
// userSession is passed as 3rd parameter
const todo = {
id: crypto.randomUUID(),
title: data.title,
description: data.description,
createdBy: session.userId,
completed: false,
createdAt: new Date().toISOString()
}

logger.info(`Todo created by ${session.userId}`)
return todo
})

addHTTPRoute({
method: 'post',
route: '/todos',
func: createTodo,
auth: true, // Requires authentication
docs: {
description: 'Create a new todo',
tags: ['todos'],
},
})

Background Tasks & Queues​

Here are examples showing scheduled tasks and background queue processing:

import { pikkuVoidFunc, addScheduledTask } from '#pikku/pikku-types.gen.js'

export const dailyReportTask = pikkuVoidFunc(
async ({ logger, emailService, analyticsService }) => {
try {
// Generate daily metrics report
const metrics = await analyticsService.getDailyMetrics()

// Send report to admin team
await emailService.sendReport({
to: 'admin@company.com',
subject: 'Daily Metrics Report',
data: {
totalUsers: metrics.activeUsers,
totalRequests: metrics.apiCalls,
avgResponseTime: metrics.avgResponseTime,
date: new Date().toISOString().split('T')[0]
}
})

logger.info(`Daily report sent - ${metrics.activeUsers} active users`)
} catch (error) {
logger.error('Failed to generate daily report:', error)
throw error // Will trigger retry logic
}
}
)

addScheduledTask({
name: 'dailyReport',
schedule: '0 8 * * *', // Daily at 8 AM
func: dailyReportTask,
timezone: 'America/New_York',
docs: {
description: 'Generate and send daily metrics report',
tags: ['reports', 'analytics'],
},
})

Quick Start​

npm create pikku@latest

Features​

  • Tiny 🔎 - The Pikku footprint is minimal. It currently relies on two small dependencies cookie and path-to-regex.
  • Deploy Anywhere 🌍 - Run your functions anywhere, as long as it's event based. Currently supporting HTTP, WebSockets and Scheduled Tasks with more coming soon.
  • Batteries Included 🔋 - Services, session management, auth, docs, it's all here..
  • Zero Boilerplate ðŸŠķ - Only write business logic in Typescript, Pikku automatically optimizes, validates and generates everything needed in a powerful framework.

Quick Intro​

Getting Started


Introduction Talk​