<html lang="en">
<head></head>
<body>

<form id="mainForm" method="post" action="https://stackblitz.com/run" target="_self">
<input type="hidden" name="project[files][README.md]" value="# Elysia Integration

Example project demonstrating Elysia web framework integration.

## Getting Started

```sh
git clone https://github.com/rivet-dev/rivet.git
cd rivet/examples/elysia
npm install
npm run dev
```


## Features

- **Elysia web framework**: Use Elysia for HTTP routing and request handling with actors
- **High-performance routing**: Built on Bun for fast request processing
- **Type-safe endpoints**: Full TypeScript type safety across HTTP and actor layers
- **Actor integration**: Call actor actions from Elysia route handlers

## Implementation

This example demonstrates integrating Elysia web framework with Rivet Actors:

- **Actor Definition** ([`src/backend/registry.ts`](https://github.com/rivet-dev/rivet/tree/main/examples/elysia/src/backend/registry.ts)): Shows how to use Elysia router with actors for HTTP endpoints

## Resources

Read more about [actions](/docs/actors/actions) and [setup](/docs/setup).

## License

MIT
">
<input type="hidden" name="project[files][package.json]" value="{&quot;name&quot;:&quot;example-elysia&quot;,&quot;version&quot;:&quot;2.0.21&quot;,&quot;private&quot;:true,&quot;type&quot;:&quot;module&quot;,&quot;scripts&quot;:{&quot;dev&quot;:&quot;npx srvx --import tsx src/server.ts&quot;,&quot;start&quot;:&quot;npx srvx --import tsx src/server.ts&quot;,&quot;check-types&quot;:&quot;tsc --noEmit&quot;,&quot;build&quot;:&quot;tsc&quot;},&quot;devDependencies&quot;:{&quot;@types/node&quot;:&quot;^22.13.9&quot;,&quot;tsx&quot;:&quot;^3.12.7&quot;,&quot;typescript&quot;:&quot;^5.5.2&quot;},&quot;dependencies&quot;:{&quot;@hono/node-server&quot;:&quot;^1.19.7&quot;,&quot;@hono/node-ws&quot;:&quot;^1.3.0&quot;,&quot;elysia&quot;:&quot;^1.4.0&quot;,&quot;rivetkit&quot;:&quot;https://pkg.pr.new/rivet-dev/rivet/rivetkit@b7a6ac3488d8d64f2cddf185312f05cf519f9413&quot;,&quot;srvx&quot;:&quot;^0.10.0&quot;},&quot;stableVersion&quot;:&quot;0.8.0&quot;,&quot;template&quot;:{&quot;technologies&quot;:[&quot;elysia&quot;,&quot;typescript&quot;],&quot;tags&quot;:[],&quot;noFrontend&quot;:true},&quot;license&quot;:&quot;MIT&quot;}">
<input type="hidden" name="project[files][tsconfig.json]" value="{
	&quot;compilerOptions&quot;: {
		&quot;target&quot;: &quot;esnext&quot;,
		&quot;lib&quot;: [&quot;esnext&quot;],
		&quot;jsx&quot;: &quot;react-jsx&quot;,
		&quot;module&quot;: &quot;esnext&quot;,
		&quot;moduleResolution&quot;: &quot;bundler&quot;,
		&quot;types&quot;: [&quot;node&quot;],
		&quot;resolveJsonModule&quot;: true,
		&quot;allowJs&quot;: true,
		&quot;checkJs&quot;: false,
		&quot;noEmit&quot;: true,
		&quot;isolatedModules&quot;: true,
		&quot;allowSyntheticDefaultImports&quot;: true,
		&quot;forceConsistentCasingInFileNames&quot;: true,
		&quot;strict&quot;: true,
		&quot;skipLibCheck&quot;: true,
		&quot;allowImportingTsExtensions&quot;: true,
		&quot;rewriteRelativeImportExtensions&quot;: true
	},
	&quot;include&quot;: [&quot;src/**/*&quot;]
}
">
<input type="hidden" name="project[files][turbo.json]" value="{
	&quot;$schema&quot;: &quot;https://turbo.build/schema.json&quot;,
	&quot;extends&quot;: [&quot;//&quot;],
	&quot;tasks&quot;: {
		&quot;build&quot;: {
			&quot;dependsOn&quot;: [&quot;rivetkit#build&quot;]
		}
	}
}
">
<input type="hidden" name="project[files][vercel.json]" value="{
	&quot;framework&quot;: &quot;elysia&quot;
}
">
<input type="hidden" name="project[files][src/actors.ts]" value="import { actor, setup } from &quot;rivetkit&quot;;

export const counter = actor({
	state: { count: 0 },
	actions: {
		increment: (c, x: number) =&gt; {
			c.state.count += x;
			return c.state.count;
		},
	},
});

export const registry = setup({
	use: { counter },
});
">
<input type="hidden" name="project[files][src/server.ts]" value="import { Elysia } from &quot;elysia&quot;;
import { createClient } from &quot;rivetkit/client&quot;;
import { registry } from &quot;./actors.ts&quot;;

const client = createClient&lt;typeof registry&gt;();

const app = new Elysia()
	.all(&quot;/api/rivet/*&quot;, (c) =&gt; registry.handler(c.request))
	.get(&quot;/increment/:name&quot;, async ({ params }) =&gt; {
		const counter = client.counter.getOrCreate(params.name);
		const newCount = await counter.increment(1);
		return `New Count: ${newCount}`;
	});

export default app;
">
<input type="hidden" name="project[description]" value="generated by https://pkg.pr.new">
<input type="hidden" name="project[template]" value="node">
<input type="hidden" name="project[title]" value="example-elysia">
</form>
<script>document.getElementById("mainForm").submit();</script>

</body></html>