Getting Started Manual Setup

The fastest way to setup SonicJs is using the npx create-sonicjs-app command. Please see the standard getting started page here.

However if you run into any issues, please follow the below steps to manually setup SonicJs.

git clone https://github.com/lane711/sonicjs.git
cd sonicjs
npm install

Rename /wrangler.example.toml to /wrangler.toml and update the 4 required Cloudfalre values:

compatibility_date = "2023-05-18"
name = "sonicjs"
workers_dev = true
main = "src/server.ts"

# Enter your account id
# This can be found at https://dash.cloudflare.com/ --> Workers & Pages
#  --> Overview, then in the right sidebar
account_id = "?????"

# Run the `wrangler kv:namespace create sonicjs` command and copy the id below
# Run the `wrangler kv:namespace create sonicjs --preview` command and copy the preview_id below
# Only update the preview_id and id, leave the binding name as "KVDATA"
kv_namespaces = [
  { binding = "KVDATA", preview_id="?????", id = "?????" }
]

# Run the `wrangler d1 create sonicjs` command and copy the id below
[[d1_databases]]
binding = "D1DATA"
database_name = "sonicjs"
database_id = "?????"

One last step; we need to run the migration scripts to create our database tables:

npm run up

Now you are ready to fire up SonicJs!

npm run dev

This will run the server locally on port 8788:

http://127.0.0.1:8788

Troubleshooting

Should you have any issues with the initial setup using the npx script, please see the manual installation instructions.

Need Help?

Please don't hesitate to open an issue if you need any additional assistance: https://github.com/lane711/sonicjs/issues

Next Steps

The next thing you will want to do is define your database table(s) and read up on SonicJs's built in caching and persistence layers.