# Fliplet Developers documentation
URL: https://developers.fliplet.com/
# Fliplet Developers documentation
Reference and guides for extending Fliplet apps with the JS API, REST API, and custom components, themes, and menus.
Customize your apps with our low code technologies
Welcome to the Fliplet developers documentation website. Here you can learn how to extend your Fliplet Apps, create new components, themes and menus.
Start by having a look at our JS API documentation to learn how to interact with our core framework and components to extend your apps.
Write code that works on any device and platform
Fliplet allows you to code once and have your app fully function on all the platforms we support, including iOS, Android and Web.
Stop worrying about compatibility and let us do the heavy lifting for you. Just focus on coding!
Integrate with on-prem data
Use our open-source Data Integration Service software to fetch data from your on-prem infrastructure and integrate a secure login system to your apps using Single Sign-On with SAML2 or other identity providers. The choice is yours!
Create complex workflows
Start with a simple proof-of-concept, then start leveraging our technology to virtually built anything else!
We have a JS API for any occasion, give it a read and find out how easy is to get started.
{% endraw %}
To get a brief introduction to the technologies we use and the stack of the platform, we recommend having a quick read at the **[Introduction to the platform](Introduction)** page of the documentation.
---
### Upcoming and newly released features
Here's a short list of requested features that are coming up on our platform in the near future or have just been released.
```
## Session Check
Check whether the user is logged in. Use this in your App shell component or route guards to protect screens.
```js
async function isLoggedIn() {
try {
var session = await Fliplet.User.getCachedSession();
// getCachedSession returns the locally cached session (works offline).
// session.entries.dataSource exists if the user logged in via email/password.
return !!(session && session.entries && session.entries.dataSource);
} catch (error) {
return false;
}
}
```
`Fliplet.User.getCachedSession()` is fast and works offline because it reads from local storage. Use it for UI decisions (show/hide content). For server-verified session checks, use `Fliplet.Session.get()` instead (requires network).
### Get the Logged-In User's Data
```js
async function getCurrentUser() {
var session = await Fliplet.User.getCachedSession();
if (!session || !session.entries || !session.entries.dataSource) {
return null; // Not logged in
}
// Returns all columns from the user's Data Source record
// e.g., { Email: 'jane@company.com', Name: 'Jane Smith', Role: 'Editor' }
return session.entries.dataSource.data;
}
```
## Logout
Clear the session and redirect to the login screen. V3 uses History API routing on every platform, so redirect via your router (or `history.pushState` + `Fliplet.Router.getBasePath()`) — never `window.location.hash`. See [V3 Routing](routing) for the full contract.
```js
// Called from a component that has a router instance in scope.
async function logout(router) {
await Fliplet.Session.logout('dataSource');
router.push('/login');
}
```
If you don't have a router handy (e.g., a framework-agnostic helper), use the History API directly:
```js
async function logout() {
await Fliplet.Session.logout('dataSource');
history.pushState({}, '', Fliplet.Router.getBasePath() + '/login');
// Trigger your router's re-render. In vanilla setups, dispatch a popstate.
window.dispatchEvent(new PopStateEvent('popstate'));
}
```
`Fliplet.Session.logout('dataSource')` clears the dataSource passport. To log out from all passport types (dataSource, saml2, flipletLogin), call `Fliplet.Session.logout()` with no arguments.
## Protected Routes with Vue Router Guards
In V3 apps using Vue Router, protect routes by checking the session before navigation. This section assumes the router was built per the V3 routing contract (History API, base path from `Fliplet.Router.getBasePath()`, routes from `Fliplet.Router.getRouteManifest()`). See the [Vue Router 4 example](routing#vue-router-4-vue-3) in the V3 Routing doc — or the sibling examples for other frameworks — before wiring the guard below.
### In the App Shell (App.vue)
Add a `beforeEach` guard to the router in your boot template's `initVueApp()` function. This does NOT go inside an SFC file. It goes in the boot HTML:
```js
// Inside initVueApp(), after creating the router:
router.beforeEach(function(to, from, next) {
// Define which routes are public (accessible without login)
var publicRoutes = ['/login', '/forgot-password', '/reset-password'];
if (publicRoutes.indexOf(to.path) !== -1) {
return next(); // Public route — allow
}
// Check session for protected routes
Fliplet.User.getCachedSession().then(function(session) {
if (session && session.entries && session.entries.dataSource) {
next(); // Logged in — allow
} else {
next('/login'); // Not logged in — redirect to login
}
}).catch(function() {
next('/login'); // Error checking session — redirect to login
});
});
```
### Route Configuration
Define your routes so the login screen is accessible without authentication:
```js
routes: [
{ path: '/', redirect: '/home' },
{ path: '/login', name: 'Login', component: function() { return loadComponent(COMPONENT_FILES.Login); } },
{ path: '/forgot-password', name: 'ForgotPassword', component: function() { return loadComponent(COMPONENT_FILES.ForgotPassword); } },
{ path: '/home', name: 'Home', component: function() { return loadComponent(COMPONENT_FILES.Home); } },
{ path: '/settings', name: 'Settings', component: function() { return loadComponent(COMPONENT_FILES.Settings); } }
]
```
## Forgot Password
Password reset uses the existing Data Source validation APIs. Code generation, storage, email delivery, and verification all happen server-side. The client orchestrates the UI steps.
The flow uses three existing APIs:
1. `dataSource.sendValidation()` — server generates a code, stores it, sends it via email
2. `dataSource.validate()` — server verifies the code, marks the user as needing a password reset
3. `Fliplet.Session.updateUserPassword()` — server updates the password
**Do NOT build custom password reset logic.** These APIs handle code generation, expiry, and verification server-side. The client never sees the reset code.
### Forgot Password Screen (Vue SFC)
```html
Reset Password
Enter your email address and we'll send you a verification code.
```
**API Reference for the forgot-password flow:**
| Step | Client calls | Server does |
|---|---|---|
| Send code | `dataSource.sendValidation({ type: 'email', where: { Email: '...' } })` | Generates code, stores on entry, sends email. Returns 204 (no info leak). |
| Verify code | `dataSource.validate({ type: 'email', where: { code: '...' }, requiresPasswordReset: true })` | Validates code, checks expiry (24h default), creates temporary session. |
| Reset password | `Fliplet.Session.updateUserPassword({ newPassword, passwordColumn })` | Updates password column on data source entry, logs out user. |
This is the same flow the V2 login widget uses. All security-critical operations (code generation, validation, password storage) happen server-side.
## Patterns — DO and DON'T
```js
// DO: Use Fliplet.Session.authorize() for email/password login
await Fliplet.Session.authorize({ passport: 'dataSource', dataSourceId: id, where: { Email, Password } });
// DON'T: Store session tokens in localStorage
// localStorage is partitioned in cross-origin iframes (Studio preview).
// Fliplet.Session handles storage internally.
// DO: Use Fliplet.User.getCachedSession() for session checks (fast, works offline)
var session = await Fliplet.User.getCachedSession();
// DON'T: Use Fliplet.Session.get() for every session check
// Session.get() makes a network request. Use getCachedSession() for UI decisions.
// DO: Use Vue Router guards for protected routes (see above)
// DON'T: Check the session inside every component's mounted() hook
// DO: Use Fliplet.Session.logout('dataSource') for dataSource logouts
// DON'T: Clear cookies or localStorage manually — the SDK handles cleanup
// DO: Show generic "Invalid email or password" errors
// DON'T: Reveal whether the email or password was wrong separately
```
## Related
- [V3 Routing](routing) — base path, route manifest, `resolveRoute`, and post-login redirect pattern.
- [V3 App Bootstrap](app-bootstrap) — the three boot-HTML constraints every V3 app must satisfy.
- [Session JS APIs](../fliplet-session) — full session API reference
- [Login Component](../components/login) — V2 login component hooks
- [Email Verification](../components/email-verification) — passwordless login flow
- [Data Source Security](../../Data-source-security) — security rules for user data sources
- [App Security](../../App-security) — app-level access control rules
---
# Fliplet Router JS API
URL: https://developers.fliplet.com/API/v3/fliplet-router.html
# Fliplet Router JS API
`Fliplet.Router` is the client-side routing helper for V3 SPA apps. It reads the route manifest from `app.settings.v3`, normalizes the base path for the current hosting context (slug-hosted web, Studio preview iframe, native shell), and performs server-ACL-backed access checks for each route.
Fliplet.Router is available on V3 apps only and is auto-loaded at boot. It depends on fliplet-core (Fliplet.Env, Fliplet.User) and fliplet-media (Fliplet.Media.getContents).
For the full routing contract, per-framework integration examples, and forbidden patterns, see [V3 routing](routing). This page is the API reference only.
## Contents
- [Methods](#methods)
- [getBasePath()](#flipletroutergetbasepath)
- [getRouteManifest()](#flipletroutergetroutemanifest)
- [getRouteConfig(path)](#flipletroutergetrouteconfigpath)
- [resolveRoute(pathOrRoute)](#flipletrouterresolveroutepathorroute)
- [Reason codes](#reason-codes)
- [Manifest shape](#manifest-shape)
- [Related](#related)
## Methods
### `Fliplet.Router.getBasePath()`
Returns the base path used by the router's history mode, normalized with a trailing slash so string concatenation doesn't produce `//route`.
**Returns:** `String`
The value depends on the hosting context:
| Context | Example value |
|---|---|
| Root-hosted web app | `/` |
| Slug-hosted web app | `/my-slug/` |
| Studio preview iframe | `/v1/apps/42/pages/99/preview/` |
| Native shell | Computed by the shell at runtime |
```js
var base = Fliplet.Router.getBasePath();
// Pass to Vue Router 4:
var history = VueRouter.createWebHistory(base);
// Pass to React Router 6:
var router = ReactRouterDOM.createBrowserRouter(routes, { basename: base });
```
Never hardcode '/'. Slug-hosted apps, preview iframes, and native shells all mount the SPA at a different base.
### `Fliplet.Router.getRouteManifest()`
Returns the route manifest stored in `app.settings.v3`. Defaults are provided for every field so callers can use the return value without null checks.
**Returns:** `Object` with the following properties:
| Property | Type | Default | Description |
|---|---|---|---|
| `routes` | `Array