This houses Instant's javascript monorepo! Here's the lay of the land:
www/
- This is a nextjs app. It’s the frontend for instantdb.com, including the dashboard and docs.
packages/
- These are where our client libraries live:
sandbox/
- We built a few example apps, to make it easy to develop against the local version of
packages
.
- We built a few example apps, to make it easy to develop against the local version of
To kick everything off:
cd client
corepack enable # enables pnpm
pnpm i
make dev
With that, all frontend code should be up and running!
Visit localhost:3000, and you'll see Instant's homepage. You can make changes to the marketing pages, dashboard, or docs here.
If you press cmd + shift + 9
, you'll also see a devtool window pop up. This can be useful if you want to enable feature flags.
Right now all backend requests will go to api.instantdb.com. If you want to develop against your local backend, load localhost:3000, and set the devBackend
flag:
localStorage.setItem("devBackend", true);
Now all requests will go to your local backend at localhost:8888. If you haven't set up a local backend, follow the server README
The instant client can show development logs. You can turn this on by writing:
localStorage.setItem("__instantLogging", true);
You can create local apps by following these steps
- On localhost:3000, click "Sign up" in the upper right corner.
- Enter your email address (or a fake one; it won't send a real email).
- Click "Send Code".
- Go back to the terminal window running the backend server. Look for a log entry showing an email. It will not have been sent, but you can read the HTML code of the email to find a 6-digit number.
- Use this number to complete the login on the website.
- You should now be in the dashboard with a newly created local app id.
You can then connect to this app in a new project with the following snippet
const APP_ID = '<your app id from your own server>'
const db = init({
appId: APP_ID,
apiURI: "http://localhost:8888",
websocketURI: "ws://localhost:8888/runtime/session",
});
All client SDKs live in packages/
.
To develop against them, we've created a few sandbox
examples. These examples let you locally test changes to the client SDK. We recommend you create an app in your dev environment and use it in each directories .env
file
Based on what you change, you'll play with different examples:
@instantdb/core
➡sandbox/vanilla-js-vite/
@instantdb/react
➡sandbox/react-nextjs/
@instantdb/react-native
➡sandbox/react-native-expo/
@instantdb/admin
➡sandbox/admin-sdk-express
Check out the sandbox READMEs to see how to run them.
If you have any questions, feel free to drop us a line on our Discord!