Quick Start
Starting a new project
To get started developing with Chopin Framework, create a new Next.js project.
After, you complete the create-next-app
flow, you can start developing using the command.
While running the dev server, your app will be available on port 3000
by default. Continue reading the next section to learn how to integrate Chopin Framework with this project.
Integrating with an existing project
To add Chopin Framework to an existing Next.js project, initialize the integration with the following command.
Then, to run your Chopin app, run the following command.
This will make your Chopin app available on port 4000
. Therefore, you can go to localhost:4000 to test and develop your app locally.
Now you are free to develop your app like a normal Next.js app, except you should access your app through port 4000
instead of 3000
.
npm run dev
and npx chopd
at the same time. Just run npx chopd
by itself after initializing.For full details, read the CLI documentation.
Handling authentication
In order to use Chopin Framework's authentication features, you need to install the @chopinframework/next
package.
Then, to get the address of the logged in user, simply use the following server-side function.
For full details, read the authentication documentation.
Fetching, random numbers, and timestamps
Any non-deterministic function (e.g. fetch
, crypto.randomBytes
, Date.now()
) executed on the server must be called using the oracle module in the @chopinframework/next
package. In other words, do this for any function that will get different results if you run it multiple times. Most code will not need this, but the listed cases are the most common times where it is needed.
In order to use the oracle module with an arbitrary non-deterministic value, you can use the Oracle.notarize
function.
For full details, read the oracle documentation.
Deployment
More information about deploying your Chopin app is coming soon.