How to Create an Online Course and Community with Next.js

Publish an Embedin course alongside your Next.js app, enable its community, and test the learner experience.

How to Create an Online Course and Community with Next.js

Use Next.js for your website or product and Embedin for your course and learner discussions. In this guide, the course lives on a dedicated HTML page served by the same site, and your Next.js app links to it.

This approach works with the App Router or Pages Router. The course page is a separate document, not a React route: opening it with a normal link gives the embed a fresh page load when learners return.

1. Prepare the course

Sign in to Embedin, create a course, and add your modules and lessons. Publish the content you want learners to see. For a self-paced course, copy the embed script from course settings. For a cohort course, publish the cohort and copy its cohort-specific script from the Cohorts page. Website embeds are unavailable while Notion-only embedding is enabled.

Under Allowed website domains, add the hostname where the page will run, such as localhost for development and academy.example.com for production. Add any separate preview hostname you use.

2. Create the course page

Create public/academy.html in your Next.js project:

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Academy</title>
  </head>
  <body>
    <h1>Academy</h1>
    <script type="module" data-courseid="YOUR_COURSE_ID" src="https://embed.embedin.com/course.js"></script>
  </body>
</html>

Replace the example script with your copied script. For a self-paced course, you can instead download the index.html course page from course settings and save it as academy.html in public. The script creates a course container at its position in the page.

Run your Next.js app and visit http://localhost:3000/academy.html, adjusting the port if necessary.

3. Link from your app

Add a normal anchor to a page or navigation component:

<a href="/academy.html">Open the academy</a>

Use an anchor rather than Next.js Link for this separate document. The embed's JavaScript module initializes on document load; removing and re-adding the script during client-side navigation does not reliably initialize it again.

The HTML page is public as a website file; learner access to course content still follows your Embedin enrollment and access settings. Do not rely on hiding the link as access control.

4. Enable and prepare Community

On the course's Layout page, select a workspace layout that supports Community and turn on Show community. Learners with access can post and comment in the course. For details, read how the course community works.

Create a welcome post, explain participation guidelines, and add a question related to the first lesson. Decide who will respond to learners and how they can request help.

5. Test before launch

  • Open the course directly and through the app link, then navigate away and return.
  • Check desktop and mobile on the live domain as well as locally.
  • Test sign-in, enrollment, a lesson, and a community post or comment as an enrolled learner. Check the view for someone without access too.
  • If the embed fails to load, check the published status, course ID, and hostname in the allowed domains.

When it works, link the academy from your site's navigation, onboarding flow, or customer portal.

Published

More guides