Synapse is a TypeScript toolchain for developing modern software. Simplify development, automate deployment, optimize performance.
curl -fsSL https://synap.sh/install | bash
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
import { Bucket } from 'synapse:srl/storage'
import { Function } from 'synapse:srl/compute'
const bucket = new Bucket()
const fn = new Function(async () => {
await bucket.put('hello.txt', 'hello, world!')
})
export async function main() {
await fn()
const data = await bucket.get('hello.txt', 'utf-8')
console.log(data)
}
useServer
.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
import { Suspense } from 'react'
import { Counter } from 'synapse:srl/storage'
import { useServer } from '@cohesible/synapse-websites'
const viewCounter = new Counter()
const inc = () => viewCounter.inc()
function Views() {
const views = useServer(inc)
return <p>{Intl.NumberFormat('en-us').format(views)} views</p>
}
export default function ViewCounter() {
return (
<Suspense fallback={<p>Loading...</p>}>
<Views />
</Suspense>
)
}